473,836 Members | 1,506 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
16 2846
Martin Jørgensen <un*********@sp am.jay.net> writes:
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?


<OT>
"info gcc" should show you the documentation for gcc, including
descriptions of all the command-line options.
</OT>

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
May 30 '06 #11
Clever Monkey <cl************ **@hotmail.com. invalid> writes:
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.


<WAY_OT>
Better yet, never included "." (the current directory) in your $PATH.
If you want to execute a program in your current directory, always
type "./whatever".
</WAY_OT>

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
May 30 '06 #12
Martin Jørgensen said:
I couldn't find any information on -W. I thought -Wall was the highest
warning level. What would -W do?


Not enough. Give yourself nightmares with -W -Wall -ansi -pedantic
-Wformat-nonliteral -Wcast-align -Wpointer-arith -Wbad-function-cast
-Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Winline
-Wundef -Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-Wno-conversion -ffloat-store -O2

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
May 30 '06 #13
"Default User" <de***********@ yahoo.com> writes:
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.


<WAY_OT>
Cygwin runs under Windows, so executables always have names ending in
".exe". You can omit the extension when you execute the program;
Cygwin does some magic to let you refer to the file as either "foo" or
"foo.exe". If there's a shell script called "foo" and an executable
called "foo.exe", it resolves the ambiguity in some manner that I
can't be bothered to remember.
</WAY_OT>

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
May 30 '06 #14
Keith Thompson wrote:
"Default User" <de***********@ yahoo.com> writes:

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.


<WAY_OT>
Cygwin runs under Windows, so executables always have names ending in
".exe". You can omit the extension when you execute the program;
Cygwin does some magic to let you refer to the file as either "foo" or
"foo.exe". If there's a shell script called "foo" and an executable
called "foo.exe", it resolves the ambiguity in some manner that I
can't be bothered to remember.
</WAY_OT>


Ah. I thought it pretty much ran whatever shell it was, and the usual
Windows rules wouldn't come into play. I'm pretty sure it's at least
case-sensitive.

Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
May 30 '06 #15
"Default User" <de***********@ yahoo.com> writes:
[A cygwin question]


I'll reply to this by e-mail.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
May 30 '06 #16

"Flash Gordon" <sp**@flash-gordon.me.uk> wrote in message
news:ab******** ****@news.flash-gordon.me.uk...
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.
--


Thanks Guys, I knew it would be something really easy :-)
May 31 '06 #17

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

Similar topics

0
2340
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
1329
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
12442
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
2920
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
2320
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
6020
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
3318
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
8547
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
6667
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
9674
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
10860
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
10604
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
9389
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
7796
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
6984
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
5659
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5831
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3116
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.