LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-20-2006, 07:22 PM   #1
GlassEyeSlim
LQ Newbie
 
Registered: Feb 2005
Location: East Coast
Distribution: FC 3
Posts: 9

Rep: Reputation: 0
Inconsistent Compilation


I'm compiling the following program:
Code:
#include <stdio.h>

void main()
{
printf("Hello World\n");
}
With the following include statement and the associated header file in the same directory as the .c file:
Code:
#include "stdio.h"
gcc will compile successfully using the following

$gcc -x none file.c

With the following include statement and the associated header file in /usr/include
Code:
#include <stdio.h>
gcc will not compile the file using any of the following

$gcc -x c file.c
$gcc -x none file.c
$gcc -std=c89 file.c

Now...how about this...

If I compile a file with the stdio.h header in the same directory, a precompiled header is kicked out: stdio.h.gch

If that .gch file is moved to /usr/include then compilation will proceed without any errors when the following statement is used:
Code:
#include <stdio.h>
According to: http://gcc.gnu.org/onlinedocs/gcc-3...ed-Headers.html

"...only one precompiled header may be used during any compilation..."

so this proves to be a solution for small projects.

More...if the following is entered, a list of syntax errors results:

$ pwd
/usr/include
$ gcc -x none stdio.h
/usr/include/stdio.h:21 error: syntax error before '*' token
......

GES
 
Old 02-21-2006, 01:37 PM   #2
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
Weird. Never seen that before. I tried to reproduce your results and couldn't...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
inconsistent bash behavior? kornelix Linux - Software 1 12-15-2005 11:06 AM
Inconsistent permissions kosmonaft Linux - General 1 11-21-2005 11:21 PM
inconsistent ip resolution blahJake Linux - Networking 0 09-20-2004 11:28 PM
inconsistent logons giri2 Mandriva 0 08-17-2004 05:50 PM
inconsistent X server? rgiggs Mandriva 3 05-11-2004 10:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration