User forums > Using Code::Blocks

Incorrect syntax, but no warning, no error.

(1/2) > >>

bud:
I use Win XP SP2 and Code::Blocks IDE with MINGW compiler 1.0-RC1.
I write a C program:
---
#include<stdio.h>
int main()
{
 int x;
 printf("Hello!");
 sacnf("%d",&x);
 return 0;
}

---
It is apparent to see the incorrect syntax "sacnf", but I compile it normally with no warning, no error.
When I run it, it can't run.
I don't know it is the problem of Code::Blocks IDE or MINGW compiler.
I think the Linux version of Code::Blocks IDE has the same problem.
Please improve it. Thanks!

Priit:
Well...i get

--- Code: ---...
.objs\main.obj:main.c:(.text+0x45): undefined reference to `sacnf'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
--- End code ---

with mingw 3.4.2.

Win xp sp2 and CB 1.0-RC1 too.
Do you get an error, when you compile that code in command line?

Ceniza:
That's totally up to the compiler to do so (show a warning/error), even more, how could the IDE really know if the function exists? You know, there could be  a "sacnf" function or a #define.

In C language it compiles but would fail when trying to link 'cause it wouldn't be able to find a _sacnf in the standard libraries.

Maybe it's just that Code::Blocks isn't reporting the linking error from GCC so what needs to be improved is the error parsing when linking (linking errors).

When you say you cannot run it I suppose it's because the executable wasn't created, right?

bud:
Well, I add "C:\Program Files\CodeBlocks\bin;C:\Program Files\CodeBlocks\include" to user variable path.
Then, I use cmd.exe to gcc the incorrect program, just get:
---
undefined reference to `sacnf'
collect2: ld returned 1 exit status
---
So I guess it is the problem of Code::Blocks.
Reply to Ceniza: After I use Code::Blocks to compile it, there is no executable file.
p.s.: Current version of GCC is 4.0.1. I hope MinGW can use newest version of GCC and Code::Blocks can use newest version of MinGW.

Ceniza:
I just tried your code with Code::Blocks CVS HEAD and it's reporting the errors here. I wonder if it's already fixed for VERSION_1_0.

BTW, GCC 4.0.1 is still buggy. 4.0.0 couldn't compile wxWidgets 2.6.1 because of an ICE (Internal Compiler Error). 4.0.1 was able to compile wxWidgets but couldn't compile STC (wxStyledTextCtrl) because of an ICE.

MinGW hasn't released GCC 4.0.1... I'm having my doubts they do it, maybe for GCC 4.0.2.

Navigation

[0] Message Index

[#] Next page

Go to full version