473,783 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Really easy cygwin / gcc question

Hi All,

Why when I complile and run the following:

#include "stdio.h"
main(void)
{
printf("test test test\n");
}

do I get no output to the screen? If I run it in the ddd debugger I get the
'test test test' in the console window, but when I run it from an Xterm get
nothing. Im wondering if stdout is set to somewhere else, but how do I check
this?

Regards
Michael
May 30 '06 #1
16 2839

Michael wrote:
Hi All,

Why when I complile and run the following:

#include "stdio.h"
main(void)
{
printf("test test test\n");
}

do I get no output to the screen? If I run it in the ddd debugger I get the
'test test test' in the console window, but when I run it from an Xterm get
nothing. Im wondering if stdout is set to somewhere else, but how do I check
this?


Your program should output "test test test" as you expect. The only
problem you have is that pre-C99 you need to return something from
`main()`. You don't tell what options you passed to your compiler and
what warnings, if any, you get.

May 30 '06 #2

Vladimir Oka wrote:
Michael wrote:
Hi All,

Why when I complile and run the following:

#include "stdio.h"
main(void)
{
printf("test test test\n");
}

do I get no output to the screen? If I run it in the ddd debugger I get the
'test test test' in the console window, but when I run it from an Xterm get
nothing. Im wondering if stdout is set to somewhere else, but how do I check
this?


Your program should output "test test test" as you expect. The only
problem you have is that pre-C99 you need to return something from
`main()`. You don't tell what options you passed to your compiler and
what warnings, if any, you get.


PS
You should also avoid implicit `int` when declaring `main()`. Spell it
out:

int main(void)

May 30 '06 #3
Hi Vladimir,

I just used:
gcc -g test.c -o test.exe

I get no warnings or errors

Thanks for your help.

Regards
Michael
"Vladimir Oka" <no****@btopenw orld.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.com.. .

Michael wrote:
Hi All,

Why when I complile and run the following:

#include "stdio.h"
main(void)
{
printf("test test test\n");
}

do I get no output to the screen? If I run it in the ddd debugger I get
the
'test test test' in the console window, but when I run it from an Xterm
get
nothing. Im wondering if stdout is set to somewhere else, but how do I
check
this?


Your program should output "test test test" as you expect. The only
problem you have is that pre-C99 you need to return something from
`main()`. You don't tell what options you passed to your compiler and
what warnings, if any, you get.

May 30 '06 #4
"Michael" <mi*********@ya hoo.com> wrote:
Why when I complile and run the following:

#include "stdio.h"
main(void)
{
printf("test test test\n");
}

do I get no output to the screen? If I run it in the ddd debugger I get the
'test test test' in the console window, but when I run it from an Xterm get
nothing. Im wondering if stdout is set to somewhere else, but how do I check
this?


You have a problem with your compiler setup. When I run this from the
compiler, I get a window that flashes on the screen and disappears
(which I can prevent by adding a command that makes it wait for input,
naturally); when I run it from a command line, it works as it should.

Ask in a newsgroup dedicated to your specific compiler suite or OS.

Richard
May 30 '06 #5
Michael wrote:

Your response belongs *under* the text you are replying to, after
deleting bits you are not replying to, not above. I've corrected it this
time.
"Vladimir Oka" <no****@btopenw orld.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.com.. .
Michael wrote:
Hi All,

Why when I complile and run the following:

#include "stdio.h"
main(void)
{
printf("test test test\n");
}

do I get no output to the screen? If I run it in the ddd debugger I get
the
'test test test' in the console window, but when I run it from an Xterm
get
nothing. Im wondering if stdout is set to somewhere else, but how do I
check
this? Your program should output "test test test" as you expect. The only
problem you have is that pre-C99 you need to return something from
`main()`. You don't tell what options you passed to your compiler and
what warnings, if any, you get.


And, as you point out in another message, you should not use implicit
int ;-)
Hi Vladimir,

I just used:
gcc -g test.c -o test.exe

I get no warnings or errors


OK, first off you are not doing enough to get all the useful warnings.
You should add -ansi -pedantic -Wall -O
Possibly -W as well, depending on your preferences.

Secondly, under C89 the compiler is not required to complain about
anything in your code (under C99, the latest standard not commonly
implemented the compiler is required to complain about the implicit
int), so the lack of warnings is not surprising.

<OT>
bash has a built in command called test so it will be running that
rather than your program. Just rename your program and it should work.
</OT>

PS, OT means Off Topic, i.e. if you want to discuss bash and its built
in test command further this is not the correct place.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
May 30 '06 #6
Michael wrote:
I just used:
gcc -g test.c -o test.exe

Never name a test script or program "test" in any POSIX environment.
The shell builtin will usually be found first, and your program will
never be found.

Use "foo" for test programs. It's why the gods created that word.
May 30 '06 #7
Flash Gordon wrote:
Michael wrote:

-snip-
> Hi Vladimir,
>
> I just used:
> gcc -g test.c -o test.exe
>
> I get no warnings or errors


OK, first off you are not doing enough to get all the useful warnings.
You should add -ansi -pedantic -Wall -O
Possibly -W as well, depending on your preferences.


I couldn't find any information on -W. I thought -Wall was the highest
warning level. What would -W do?
Best regards
Martin Jørgensen

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk
May 30 '06 #8
Michael wrote:
Hi Vladimir,

I just used:
gcc -g test.c -o test.exe

I get no warnings or errors

Thanks for your help.


Don't top-post. Your replies belong following or interspersed with the
quotes.

As one person already mentioned, there is a progam called "test" on
most UNIX systems. Also, if you're running from the CYGWIN shell you
can't leave off the extension when you run it the way you can with
Windows or DOS. That's why progams developed on UNIX systems tend not
to have the .exe extension, as it doesn't mean (or do) anything special.

Brian
May 30 '06 #9
Martin Jørgensen wrote:
Flash Gordon wrote:
Michael wrote:

-snip-
> Hi Vladimir,
>
> I just used:
> gcc -g test.c -o test.exe
>
> I get no warnings or errors


OK, first off you are not doing enough to get all the useful warnings.
You should add -ansi -pedantic -Wall -O
Possibly -W as well, depending on your preferences.


I couldn't find any information on -W. I thought -Wall was the highest
warning level. What would -W do?


It enables more warnings. Ask on one og the GNU gcc groups for more
information, such as gnu.gcc.help remembering to tell them what version
of gcc you are using.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
May 30 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2337
by: dw | last post by:
Pehaba, does anyone knows how to install MySQLdb on cygwin? - test device: MySQLdb 0.9.2.0 targz + cygwin 1.5.7-cr-0x9e + python 2.3.3 on cygwin + mysql 4.0.17 win32 - modified setup.py's using thread library.. NO, library + include
0
1327
by: Pekka Niiranen | last post by:
Hi, I started cygwin shell with command subprocess.call("c:\\cygwin\\cygwin.bat") from Python 2.4. Shell works fine but the fonts/layout are set according to program "c:\winnt\system32\cmd.exe".
2
12435
by: JustSomeGuy | last post by:
I'm writing a socket class using unix flavor sockets. I'm developing on win2k with M$ visual studio 6.0. I have cygwin installed and would like to use its socket header files: #ifdef UNIX #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #else // Windows. #include </cygwin/usr/include/sys/types.h>
1
2917
by: alex | last post by:
Hello I have some c++ code, which has been happily developped in the linux/unix world. Everything has always been compiled with different compiler (intel, KAI, g++...) and gnu makefiles For some obscure reasons, I have to make all this work in Windows, where I have very little experience. I've installed cygwin and everything is going well using the provided g++ compiler.
7
2311
by: rihad | last post by:
Hi, I have this problem: when reading a M$ Windows text file under Windows in text mode (fopen("blah", "r")) the Windows newline sequence, \r\n is returned as is, i.e. it's not replaced by a single '\n'. Is this the correct behaviour? But doesn't it make writing portable programs a bit harder? It would be nice if whatever-newline-sequence-the-platform-has were replaced by a single \n, i.e. the "C platform" line terminator. Like ints are...
52
6004
by: lcw1964 | last post by:
Greetings, all, I am trying to port a little bit of math code to gcc, that in the original version used the long double version of several functions (in particular, atanl, fabsl, and expl). I get a complie-time "unidentified reference" error to the expl() calls, but gcc seems to digest atanl and fabsl just fine. Changing expl to exp cures the compile time problem, but I get at best double precision in the final results. I am assuming...
0
3308
by: dot | last post by:
I spent a few headache filled days trying to use GMP on windows (XP pro) I finally got it to work and since I found little help on the Web I thought someone might find what i did useful. Creating an environment suitable for GMP programming. 1) Create 'cygwin' environment (see below) 2)add GMP to the cygwin directory (see below)
10
8545
by: Gotch | last post by:
Hi all, I've installed the CDT plugin for Eclipse and I want to use it to work on C/C++ projects under Cygwin. It works, in fact it compiles and runs the usual helloworld c++ program. Now it comes difficult when I try to add external libs. Such as... GTK. Let's explain what I tried. (oh well, I'm using Eclipse Europa 3.3.1 and CDT 4.0.1). First I just added the path of the cygwin includes throug the project->properties- GNU C the path to...
2
6662
myusernotyours
by: myusernotyours | last post by:
Hi All, Am working on a Java application in which I have to use the JNI to Interface with some native code for both windows and unix. Am using netbeans IDE with the C/C++ pack installed. Am also using Cygwin as my compiler (gcc), this is ostensibly because I hope this compiler will also compile the unix native libraries since I don't have a Linux installation. (I am working on a personal project from the office and can't get linux installed)....
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10083
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.