Menu

Compile problem with gcc in ANSI-Mode

Jens Remus
2004-04-28
2012-09-26
  • Jens Remus

    Jens Remus - 2004-04-28

    Hi!

    I am learning ANSI C at University of Applied Sciences Wedel, Germany. At school we use gcc unter Linux or MS Visual C. At home I wanted to use Dev-C++ (Version 4.9.8.7). Our teacher want us to use the compiler flags "-ansi -pedantic -Wall -Werror".

    When I compile a file in Dev-C++ it results in the following errors:
    gcc.exe "E:\Jens Remus\FH Wedel\C bung\ueb02\ueb02.c" -o "E:\Jens Remus\FH Wedel\C bung\ueb02\ueb02.exe"   -ansi -pedantic -Wall -Werror -g3 -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"-g3
    In file included from C:/Dev-Cpp/include/stdio.h:42,
                     from E:/Jens Remus/FH Wedel/C bung/ueb02/ueb02.c:1:
    C:/Dev-Cpp/include/stddef.h:6:2: #include_next is a GCC extension
    In file included from C:/Dev-Cpp/include/stdio.h:44,
                     from E:/Jens Remus/FH Wedel/C bung/ueb02/ueb02.c:1:
    C:/Dev-Cpp/include/stdarg.h:6:2: #include_next is a GCC extension
    cc1.exe: warnings being treated as errors
    In file included from E:/Jens Remus/FH Wedel/C bung/ueb02/ueb02.c:1:
    C:/Dev-Cpp/include/stdio.h:288: warning: ISO C89 does not support `long long'
    In file included from C:/Dev-Cpp/include/string.h:40,
                     from E:/Jens Remus/FH Wedel/C bung/ueb02/ueb02.c:2:
    C:/Dev-Cpp/include/stddef.h:6:2: #include_next is a GCC extension

    When I compile from command-line omitting the -I parameter gcc doen't complain about non-ANSI-confom stdio.h:
    gcc.exe "E:\Jens Remus\FH Wedel\C bung\ueb02\ueb02.c" -o "E:\Jens Remus\FH Wedel\C bung\ueb02\ueb02.exe" -ansi -pedantic -Wall -Werror

    Using Sysinternals File Monitor I found out that in both cases the same stdio.h from C:\Dev-Cpp\include is used.

    Why does the compiler complain when using the -I parameter? Is there a way to tell Dev-Cpp to omit the -I parameter?

    I found the -Wno-long-long parameter, but then gcc is still compaining about the #include_next stuff.

    Thanks in advance,
    Jens

     
    • Anonymous

      Anonymous - 2004-04-28

      Remove the -pedantic, it breaks the gcc specific #include_next which is used in many of the system headers to re-direct inclusion to platform specific headers.

      The solution is to use the -isystem instead of -I, this switcheds off certain error messaged for system headers. Unfortunately Dev-C++ generates these options for you. I think I entered an RFE over a year ago about this problem.

      Clifford

       
    • Jens Remus

      Jens Remus - 2004-04-28

      The Problem is that the homework we have to do must compile using gcc -ansi -pedantic -Wall -Werror. The teacher want's this. Is there a switch like -Wno-long-long for the #include_next?

      -Jens

       
    • Jim W.

      Jim W. - 2004-04-28

      Jens --

      Try this:

      Tools > Compiler Options > Directories > C Includes.

      Then use the little folder icon to find something like this (might be different on your setup):

      C:\Dev-Cpp\lib\gcc-lib\mingw32\3.2\include

      (Yes, it's an include directory below a lib directory.)

      Add it.  Then use the arrows to the right to make it the first entry.

      Be sure to click OK.  Let us know if it works....

      -- Jim.

       
    • Jens Remus

      Jens Remus - 2004-04-29

      Hi Jim!

      Thanks! It did it! With your additional includes and the -Wno-long-long switch it compiles without errors. :)

      -Jens

       
    • Anonymous

      Anonymous - 2004-04-29

      Good work around, but beware, you have referenced a gcc version specific folder.

      If you upgrade the compiler, the project will either not compile or reference the incorrect include file. (that is what the #include_next stuff is supposed to solve - its a good thing, its just the fault of Dev-C++ using -I instead of -isystem.

      Clifford

       
    • Jim W.

      Jim W. - 2004-04-29

      I don't know for sure whether or not the work-around could possibly have any side effects, so (Jens) watch for any problems that could involve those headers.  I just wanted to see if there might be a quick fix so you could do your homework and stay within the course "parameters".

      It's worth taking a look at the README file in
      lib\gcc-lib\mingw32\3.2\include
      in any case.  Note, also, the contents of the header files in there, and of their same-name counterparts in the default include directory.

      There are other ways to "fix" things, but I was glad to hear that a simple one "seems to work"....

      I also noticed that there was no sign of the problems when using the CygWin port of GCC.  That is a more "Unix-like" environment (search here, or Google, on CygWin), and might be a good alternative for working within the constraints of an academic setting.  It can be set up to work with Dev-C++, but with some effort.

      Jens, good luck with your studies!

      -- Jim.

       
    • Wayne Keen

      Wayne Keen - 2004-04-29

      Note Cygwin includes a newer version of GCC, version 3.3 (Dev uses 3.2).  I don't think that should have much bearing on things, but given the constraints of class I thought I would mention it.

      Wayne

       
    • Jim W.

      Jim W. - 2004-04-29

      By the way, Jens or anyone who comes across this thread should note that you should avoid directories and/or filenames with spaces, such as:
      E:/Jens Remus/FH Wedel/C bung/ueb02/ueb02.c .

      That was not the issue in this case, but it, too is worth noting.

      -- Jim.

       
    • aditsu

      aditsu - 2004-05-05

      I usually take the stddef.h and stdarg.h from the lib\gcc-lib\mingw32\3.2\include folder and copy them over the ones in the include folder
      (just another workaround)

      Adrian

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.