Dev-C++ 4.9.9.2, header caching enabled
Windows XP 2002, Service Pack 3
When I specify compiler options -ansi and -pedantic I get multiple errors in standard header files when compiling from the Dev-C++ environment. I do not get these errors when compiling from the command line. Could this be because I have header caching enabled? I can't figure out how to disable it.
In file included from C:/Dev-Cpp/include/stdlib.h:22,
from temp.c:1:
C:/Dev-Cpp/include/stddef.h:6:2: warning: #include_next is a GCC extension
In file included from temp.c:1:
C:/Dev-Cpp/include/stdlib.h:467: warning: ISO C90 does not support long long'
C:/Dev-Cpp/include/stdlib.h:467: warning: ISO C90 does not supportlong long'
C:/Dev-Cpp/include/stdlib.h:469: warning: ISO C90 does not support long long'
C:/Dev-Cpp/include/stdlib.h:469: warning: ISO C90 does not supportlong long'
C:/Dev-Cpp/include/stdlib.h:471: warning: ISO C90 does not support long long'
C:/Dev-Cpp/include/stdlib.h:472: warning: ISO C90 does not supportlong long'
C:/Dev-Cpp/include/stdlib.h:474: warning: ISO C90 does not support long long'
C:/Dev-Cpp/include/stdlib.h:475: warning: ISO C90 does not supportlong long'
C:/Dev-Cpp/include/stdlib.h:478: warning: ISO C90 does not support `long long'
Execution terminated
Compilation successful
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks. If I remove the -I"C:/Dev-Cpp/include" from the makefile, then make from the command line, everything works fine. But when I make from the GUI it just recreates the makefile with the offensive -I. How do I tell it to stop doing that (other than specifying a custom makefile)?
By the way, I tried the -isystem option, but that didn't help.
Background: My problem here is to produce C90 code. I don't use Dev-C++ (though I'm thinking about it), but I teach a class in C and some of my students do. The code they write has to be compatible with just about any C90-compliant compiler. If I compile with -std=c89 -Wall -Werror gcc will happily compile code with nested functions and mixed declarations/procedural code without any warnings or errors (see below). To get the desired result I have to add -pedantic.
If you have any suggestions how to accomplish this without using -pedantic please let me know.
> when I make from the GUI it just recreates the makefile
> with the offensive -I. How do I tell it to stop doing that
Remove the path from the project include directories list. Project->Project options->Directories
> By the way, I tried the -isystem option, but that didn't help.
You misunderstood. I did not suggest that it was a solution; it is not. What I said is that if Dev-C++ generated command lines that used that for system header paths, then the pedantic warnings would be suppressed. That is what -isystem is for. Thinking about it, it can be a solution if you remove the standard header path from the directories list and then add it as a general comand line option with -isystem rather than -I. However it seems that you have your system environment correctly set up for command line builds, so you may not need to do even that, but your students may need to do so.
When you get it working, I suggest that you create a new project template and package it as a DevPak so that you can ensure all your students get the same set-up.
However a better solution is to impose a course tool and make them use it or walk. Better yet teach them C++.
> The code they write has to be compatible with just about any C90-compliant compiler.
I suggest that you then only need -std=C90 and not -pedantic. I compile code on many platforms with many compilers, both GNU and commercial. I have never needed to use -pedantic. You could of course impose a course tool. Personally I would not recommend Dev-C++ when VC++ 2008 Express is free and has a working debugger. Using a debugger effectively is an essential part of software development, you should be teaching it to your students right after 'hello, world' or whatever. You are teaching the use of the debugger right!? Dev-C++'s debugger is worse than useless.
> gcc will happily compile code with nested functions
Really!? Yikes! So it does, I never knew that. However are your students really going to try that unless they are taught that it exists? Well mabe if they are Pascal programmers.
If you cannot take my advice not to use Dev-C++ (why wouldn't your students want a working debugger!?), then, I suggest that you remove teh standard header folder as I suggested and add -isystem "C:/Dev-Cpp/include" to the gneeral compiler options box. If you don't want to create a project template, add these to the Tools->Compiler dialog rather than the Project options dialog, then they will be applied to all new projects. When you get it right the Dev-C++ generated command line should look something like:
> By the way, C:/Dev-Cpp/include is not listed in
> Project->Project options->Directories.
My apologies. I took my own advice a long time ago and no longer have Dev-C++ installed. You did look in the "Include Directories" tab I take it? (I did not see the need to specify which directories tab!)
> It comes from some magical place deep
> in the makefile generation logic.
I can assure you that there is very little 'magic' about Dev-C++. It is my recollection that is flawed. If not there, the setting is then defined in Tools->Compiler Options->Directories (again in the "Includes" tab).
It is somewhat confused by the fact that some settings in Tools->Compiler options are inherited by a project on creation only, and others are applied to all projects even after creation.
I suggest then that you make all the necessary changes to the Tools->Compiler options dialog.
I have no doubt that it can be made to wore, I do doubt however the wisdom of trying to do so.
It is not unusual (in fact quite the opposite) to impose course specific resources and tools on students (unfortunately that often means some ancient 16bit DOS Borland Turbo compiler). It may be worth suggesting to your students that they test on more than one compiler - that is a good debug technique in any case. If you specify what compiler/tools you are using to evaluate their work, they would be unwise in my opinion to use something else.
Enforcing a course style or rules may also help (it will certainly simplify your marking). For example you might ban the use of compiler syntax and language features not described in K&R 2nd ed, or whatever text you are using. It is then down to the student to remain within the language subset, not for the compiler to enforce. This is an artificial constraint perhaps, but it is common to do that merely to make fair assessment simpler.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Note the explicit standard header path using teh -I option. For it to work when the standard header path is explicitly specified, Dev-C++ would have to use the -isystem option thus:
The simple solution is not to specify -pedantic, as its name suggests it is hardly ever necessary. Also you should read the documentation very carefully, it is likely that -ansi and -pedantic do not actually do what you are assuming they do, or actually desire. For example I can think of few good reasons to disable "recognition of C++ style `//' comments".
By the way, C:/Dev-Cpp/include is not listed in Project->Project options->Directories. It comes from some magical place deep in the makefile generation logic.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dev-C++ 4.9.9.2, header caching enabled
Windows XP 2002, Service Pack 3
When I specify compiler options -ansi and -pedantic I get multiple errors in standard header files when compiling from the Dev-C++ environment. I do not get these errors when compiling from the command line. Could this be because I have header caching enabled? I can't figure out how to disable it.
Sample Code:
include <stdlib.h>
void funk()
{
}
Command line operation:
C:\Dev-Cpp\project1>gcc --version
gcc (GCC) 3.4.2 (mingw-special)
Copyright (C) 2004 (etc.)
C:\Dev-Cpp\project1>gcc -I. -ansi -pedantic -c temp.c
C:\Dev-Cpp\project1>
Dev-C++ compiler log:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\project1\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\project1\Makefile.win" temp.o
gcc.exe -c temp.c -o temp.o -I"C:/Dev-Cpp/include" -I"." -std=c89 -pedantic
In file included from C:/Dev-Cpp/include/stdlib.h:22,
from temp.c:1:
C:/Dev-Cpp/include/stddef.h:6:2: warning: #include_next is a GCC extension
In file included from temp.c:1:
C:/Dev-Cpp/include/stdlib.h:467: warning: ISO C90 does not support
long long' C:/Dev-Cpp/include/stdlib.h:467: warning: ISO C90 does not support
long long'C:/Dev-Cpp/include/stdlib.h:469: warning: ISO C90 does not support
long long' C:/Dev-Cpp/include/stdlib.h:469: warning: ISO C90 does not support
long long'C:/Dev-Cpp/include/stdlib.h:471: warning: ISO C90 does not support
long long' C:/Dev-Cpp/include/stdlib.h:472: warning: ISO C90 does not support
long long'C:/Dev-Cpp/include/stdlib.h:474: warning: ISO C90 does not support
long long' C:/Dev-Cpp/include/stdlib.h:475: warning: ISO C90 does not support
long long'C:/Dev-Cpp/include/stdlib.h:478: warning: ISO C90 does not support `long long'
Execution terminated
Compilation successful
Thanks. If I remove the -I"C:/Dev-Cpp/include" from the makefile, then make from the command line, everything works fine. But when I make from the GUI it just recreates the makefile with the offensive -I. How do I tell it to stop doing that (other than specifying a custom makefile)?
By the way, I tried the -isystem option, but that didn't help.
Background: My problem here is to produce C90 code. I don't use Dev-C++ (though I'm thinking about it), but I teach a class in C and some of my students do. The code they write has to be compatible with just about any C90-compliant compiler. If I compile with -std=c89 -Wall -Werror gcc will happily compile code with nested functions and mixed declarations/procedural code without any warnings or errors (see below). To get the desired result I have to add -pedantic.
If you have any suggestions how to accomplish this without using -pedantic please let me know.
build log:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\project1\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\project1\Makefile.win" temp.o
gcc.exe -c temp.c -o temp.o -I"C:/Dev-Cpp/include" -I"." -std=c89 -Wall -Werror
Execution terminated
Compilation successful
sample code:
include <stdio.h>
void funk()
{
printf( "funk\n" );
int inx = 0;
static void gunk( int );
gunk( inx );
void gunk( int num )
{
printf( "gunk: %d\n", num );
}
}
> when I make from the GUI it just recreates the makefile
> with the offensive -I. How do I tell it to stop doing that
Remove the path from the project include directories list. Project->Project options->Directories
> By the way, I tried the -isystem option, but that didn't help.
You misunderstood. I did not suggest that it was a solution; it is not. What I said is that if Dev-C++ generated command lines that used that for system header paths, then the pedantic warnings would be suppressed. That is what -isystem is for. Thinking about it, it can be a solution if you remove the standard header path from the directories list and then add it as a general comand line option with -isystem rather than -I. However it seems that you have your system environment correctly set up for command line builds, so you may not need to do even that, but your students may need to do so.
When you get it working, I suggest that you create a new project template and package it as a DevPak so that you can ensure all your students get the same set-up.
However a better solution is to impose a course tool and make them use it or walk. Better yet teach them C++.
> The code they write has to be compatible with just about any C90-compliant compiler.
I suggest that you then only need -std=C90 and not -pedantic. I compile code on many platforms with many compilers, both GNU and commercial. I have never needed to use -pedantic. You could of course impose a course tool. Personally I would not recommend Dev-C++ when VC++ 2008 Express is free and has a working debugger. Using a debugger effectively is an essential part of software development, you should be teaching it to your students right after 'hello, world' or whatever. You are teaching the use of the debugger right!? Dev-C++'s debugger is worse than useless.
> gcc will happily compile code with nested functions
Really!? Yikes! So it does, I never knew that. However are your students really going to try that unless they are taught that it exists? Well mabe if they are Pascal programmers.
If you cannot take my advice not to use Dev-C++ (why wouldn't your students want a working debugger!?), then, I suggest that you remove teh standard header folder as I suggested and add -isystem "C:/Dev-Cpp/include" to the gneeral compiler options box. If you don't want to create a project template, add these to the Tools->Compiler dialog rather than the Project options dialog, then they will be applied to all new projects. When you get it right the Dev-C++ generated command line should look something like:
gcc.exe -c temp.c -o temp.o -I"." -std=c89 -Wall -Werror -isystem C:/Dev-Cpp/include
Clifford
> By the way, C:/Dev-Cpp/include is not listed in
> Project->Project options->Directories.
My apologies. I took my own advice a long time ago and no longer have Dev-C++ installed. You did look in the "Include Directories" tab I take it? (I did not see the need to specify which directories tab!)
> It comes from some magical place deep
> in the makefile generation logic.
I can assure you that there is very little 'magic' about Dev-C++. It is my recollection that is flawed. If not there, the setting is then defined in Tools->Compiler Options->Directories (again in the "Includes" tab).
It is somewhat confused by the fact that some settings in Tools->Compiler options are inherited by a project on creation only, and others are applied to all projects even after creation.
I suggest then that you make all the necessary changes to the Tools->Compiler options dialog.
I have no doubt that it can be made to wore, I do doubt however the wisdom of trying to do so.
It is not unusual (in fact quite the opposite) to impose course specific resources and tools on students (unfortunately that often means some ancient 16bit DOS Borland Turbo compiler). It may be worth suggesting to your students that they test on more than one compiler - that is a good debug technique in any case. If you specify what compiler/tools you are using to evaluate their work, they would be unwise in my opinion to use something else.
Enforcing a course style or rules may also help (it will certainly simplify your marking). For example you might ban the use of compiler syntax and language features not described in K&R 2nd ed, or whatever text you are using. It is then down to the student to remain within the language subset, not for the compiler to enforce. This is an artificial constraint perhaps, but it is common to do that merely to make fair assessment simpler.
Clifford
Your command line invokation is not identical to that Dev-C++ is generating:
gcc.exe -c temp.c -o temp.o -I"C:/Dev-Cpp/include" -I"." -std=c89 -pedantic
Note the explicit standard header path using teh -I option. For it to work when the standard header path is explicitly specified, Dev-C++ would have to use the -isystem option thus:
gcc.exe -c temp.c -o temp.o -isystem "C:/Dev-Cpp/include" -I"." -std=c89 -pedantic
but it does not - rightly or wrongly.
The simple solution is not to specify -pedantic, as its name suggests it is hardly ever necessary. Also you should read the documentation very carefully, it is likely that -ansi and -pedantic do not actually do what you are assuming they do, or actually desire. For example I can think of few good reasons to disable "recognition of C++ style `//' comments".
Check here:
http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/C-Dialect-Options.html#C-Dialect-Options
http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Warning-Options.html#Warning-Options
especially the fourth and fifth paragraphs of the entry on -pedantic.
I note that you are not using -Wall -Werror which will be far more effective at improving your code quality if that is what you intended.
Clifford
Insisting that students use a specific compiler is not an option. I will take your advice and recommend against using Dev-C++.
Thanks,
Jack
By the way, C:/Dev-Cpp/include is not listed in Project->Project options->Directories. It comes from some magical place deep in the makefile generation logic.