By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,919 Members | 1,587 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,919 IT Pros & Developers. It's quick & easy.

C code in Dev-Cpp

P: n/a
What can I do to get Dev-Cpp to compile C code? Whenever I try
compiling C code the compiler complains about the headers.

For instance the code:(I do name the code with extension.c)

#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)
{

char buffer[100];

strcpy(buffer, argv[1]);
printf("%s\n", buffer);

}

gives me the errors:

Compiler: Default compiler
Executing gcc.exe...
gcc.exe "C:\cCode\vulnerable.c" -o "C:\cCode\vulnerable.exe" -ansi -
pedantic -Wall -g3 -O0 -fexceptions -g3 -I"C:\DEV-CPP\include" -L"C:
\DEV-CPP\lib" -g3
In file included from C:/DEV-CPP/include/stdio.h:26,
from C:\cCode\vulnerable.c:1:
C:/DEV-CPP/include/stddef.h:6:2: warning: #include_next is a GCC
extension
In file included from C:/DEV-CPP/include/stdio.h:28,
from C:\cCode\vulnerable.c:1:
C:/DEV-CPP/include/stdarg.h:6:2: warning: #include_next is a GCC
extension
In file included from C:\cCode\vulnerable.c:1:
C:/DEV-CPP/include/stdio.h:330: warning: ISO C90 does not support
`long long'

In file included from C:/DEV-CPP/include/string.h:24,
from C:\cCode\vulnerable.c:2:
C:/DEV-CPP/include/stddef.h:6:2: warning: #include_next is a GCC
extension
C:\cCode\vulnerable.c: In function `main':

C:\cCode\vulnerable.c:12: warning: control reaches end of non-void
function

Execution terminated
Compilation successful

Jun 16 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"waltbrad" <wa******@hotmail.comwrote in message
news:11**********************@o61g2000hsh.googlegr oups.com...
What can I do to get Dev-Cpp to compile C code? Whenever I try
compiling C code the compiler complains about the headers.

For instance the code:(I do name the code with extension.c)

#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)
{

char buffer[100];

strcpy(buffer, argv[1]);
printf("%s\n", buffer);

}

gives me the errors:

Compiler: Default compiler
Executing gcc.exe...
gcc.exe "C:\cCode\vulnerable.c" -o "C:\cCode\vulnerable.exe" -ansi -
pedantic -Wall -g3 -O0 -fexceptions -g3 -I"C:\DEV-CPP\include" -L"C:
\DEV-CPP\lib" -g3
In file included from C:/DEV-CPP/include/stdio.h:26,
from C:\cCode\vulnerable.c:1:
C:/DEV-CPP/include/stddef.h:6:2: warning: #include_next is a GCC
extension
In file included from C:/DEV-CPP/include/stdio.h:28,
from C:\cCode\vulnerable.c:1:
C:/DEV-CPP/include/stdarg.h:6:2: warning: #include_next is a GCC
extension
In file included from C:\cCode\vulnerable.c:1:
C:/DEV-CPP/include/stdio.h:330: warning: ISO C90 does not support
`long long'

In file included from C:/DEV-CPP/include/string.h:24,
from C:\cCode\vulnerable.c:2:
C:/DEV-CPP/include/stddef.h:6:2: warning: #include_next is a GCC
extension
C:\cCode\vulnerable.c: In function `main':

C:\cCode\vulnerable.c:12: warning: control reaches end of non-void
function

Execution terminated
Compilation successful
Umm.. "compilation successful". Those are warnings. Those warnings are
saying that stdio.h, stdarg.h and string.h contain GCC specific instructions
(#include_next and long long) that are not ISO C90. Yet it would seem that
you continue to get your program. Warning != error.

Jun 16 '07 #2

P: n/a
>
Umm.. "compilation successful". Those are warnings. Those warnings are
saying that stdio.h, stdarg.h and string.h contain GCC specific instructions
(#include_next and long long) that are not ISO C90. Yet it would seem that
you continue to get your program. Warning != error.
What's more the reference to C90 proves that the OP is compiling C not C++.

To the OP, -Wall (i.e. turn on all warnings) is the problem. Personally
I wouldn't be happy with a compiler that couldn't compile standard C
header files without warnings but it's your choice.

john
Jun 16 '07 #3

P: n/a

John Harrison <jo*************@hotmail.comwrote in message
news:Mc*************@newsfe7-win.ntli.net...

Umm.. "compilation successful". Those are warnings. Those warnings are
saying that stdio.h, stdarg.h and string.h contain GCC specific
instructions
(#include_next and long long) that are not ISO C90. Yet it would seem
that
you continue to get your program. Warning != error.

What's more the reference to C90 proves that the OP is compiling C not
C++.
>
To the OP, -Wall (i.e. turn on all warnings) is the problem. Personally
I wouldn't be happy with a compiler that couldn't compile standard C
header files without warnings but it's your choice.
john
I wonder if turning on 'C99' would help.
-std=c99
or:
-std=iso9899:1999
or:
-std=gnu99 // C99 + GNU extensions

--
Bob R
POVrookie
Jun 16 '07 #4

P: n/a
On Jun 16, 11:26 am, waltbrad <waltb...@hotmail.comwrote:
What can I do to get Dev-Cpp to compile C code? Whenever I try
compiling C code the compiler complains about the headers.

For instance the code:(I do name the code with extension.c)

#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)
{

char buffer[100];

strcpy(buffer, argv[1]);
printf("%s\n", buffer);

}

gives me the errors:

Compiler: Default compiler
Executing gcc.exe...
gcc.exe "C:\cCode\vulnerable.c" -o "C:\cCode\vulnerable.exe" -ansi -
pedantic -Wall -g3 -O0 -fexceptions -g3 -I"C:\DEV-CPP\include" -L"C:
\DEV-CPP\lib" -g3
In file included from C:/DEV-CPP/include/stdio.h:26,
from C:\cCode\vulnerable.c:1:
C:/DEV-CPP/include/stddef.h:6:2: warning: #include_next is a GCC
extension
In file included from C:/DEV-CPP/include/stdio.h:28,
from C:\cCode\vulnerable.c:1:
C:/DEV-CPP/include/stdarg.h:6:2: warning: #include_next is a GCC
extension
In file included from C:\cCode\vulnerable.c:1:
C:/DEV-CPP/include/stdio.h:330: warning: ISO C90 does not support
`long long'

In file included from C:/DEV-CPP/include/string.h:24,
from C:\cCode\vulnerable.c:2:
C:/DEV-CPP/include/stddef.h:6:2: warning: #include_next is a GCC
extension
C:\cCode\vulnerable.c: In function `main':

C:\cCode\vulnerable.c:12: warning: control reaches end of non-void
function

Execution terminated
Compilation successful
the last warning is due to declaration of main as returning int but
providing a body that returns nothing.Put this line before '}' of the
main function:

return 0;

and one warning is reduced.

Jun 16 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.