473,726 Members | 2,142 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 2834

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
2333
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
1319
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
12432
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
2912
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
2309
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
5981
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
3303
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
8535
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
6660
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
8890
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
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9402
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...
0
9259
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9120
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...
1
6702
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...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4785
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2157
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.