C code in Dev-Cpp

W

waltbrad

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
 
J

Jim Langston

waltbrad said:
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.
 
J

John Harrison

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
 
B

BobR

John Harrison said:
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
 
T

terminator

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,591
Members
45,103
Latest member
VinaykumarnNevatia
Top