Author Topic: Incorrect syntax, but no warning, no error.  (Read 7744 times)

bud

  • Guest
Incorrect syntax, but no warning, no error.
« on: August 02, 2005, 06:13:03 pm »
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!
« Last Edit: August 02, 2005, 06:14:37 pm by bud »

Priit

  • Guest
Re: Incorrect syntax, but no warning, no error.
« Reply #1 on: August 02, 2005, 06:24:28 pm »
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)

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?

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Incorrect syntax, but no warning, no error.
« Reply #2 on: August 02, 2005, 06:28:41 pm »
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

  • Guest
Re: Incorrect syntax, but no warning, no error.
« Reply #3 on: August 02, 2005, 06:41:12 pm »
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.
« Last Edit: August 02, 2005, 06:45:51 pm by bud »

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Incorrect syntax, but no warning, no error.
« Reply #4 on: August 02, 2005, 07:09:02 pm »
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.

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Incorrect syntax, but no warning, no error.
« Reply #5 on: August 02, 2005, 07:16:22 pm »
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.
IIRC, the fact that GCC went to version 4 is not because it's a big improvement over previous versions (yet), but because of major internal changes in the way it works, that should lead to improved optimization opportunities and cleaner internals.
This means it might be best to wait a bit until a lot of the newly introduced bugs have been worked out (and I don't think that'll have happened in a .0.1 release).
Though I have heard compile times for unoptimized C++ programs are greatly improved, which is good news for the future :).

And I guess what Ceniza posted while I was typing this confirms it's best to wait

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Incorrect syntax, but no warning, no error.
« Reply #6 on: August 02, 2005, 07:33:57 pm »
Uxrae: You've heard right, and it's in GCC's website. They've been reported up to 25% speed up compiling C++ code without optimisations and the main changes for 4.x.x are Tree SSA (which would help to improve code optimisation) and a new and faster hand-written parser (C++ only for 4.0.x, C for 4.1.x).

What I'm really waiting for is the 4.1.x series (4.1.0 should be released soon) but I bet the first ones will be really buggy.

So, even when it's almost getting off-topic, I recommend using GCC 3.4.3 in the meanwhile (I had some problems with 3.4.4 because of some undefined references, and the workaround wasn't that helpful).

BTW, GCC 3.4.5 could be released soon too (at least I got that one in my Linux box as a pre-release).