Author Topic: Error "assert.h: missing binary operator" when creating/compiling new projects  (Read 15093 times)

Offline ascii_moe

  • Multiple posting newcomer
  • *
  • Posts: 13
Hi all,

I know that this topic has already been discussed two times in this forum: 

http://forums.codeblocks.org/index.php/topic,7274.0.html
  and
http://forums.codeblocks.org/index.php?topic=11911.msg81009

Since both threads didn't solve my problem - the first one didn't work and the second one seemed to be fixed, but it was never explained, HOW... - I'm going to start another try:

I am new to Code::Blocks and already went through several HowTo's, etc. My problem is as follows:

Yesterday I created a new project, compiled it, tested it - everything worked fine as the times before.

Today I created another project, but now compiling fails with an error message:
" /usr/include/assert.h:39:42: Error: missing binary operator before Token »(« "

The curiosity is:
This happens every time I create a NEW project. But when I change code of YESTERDAY's project, save and compile it everything works perfect!?
No error occurs, compiling succeeds.

I've checked the compiler and linker setting of both projects. They're exactly the same! - What is going on here?

Below I've listed some Build/Log output.

Thanks in advance for any help or useful information!
(And I promise I will post the solution, if there will be one !!!)


Regards,
Thomas



1) -------------- Build: Debug in HiWorld ---------------

Precompiling header: wx_pch.h
In Datei, eingefügt von /usr/local/include/wx-2.8/wx/debug.h:18,
                 von /usr/local/include/wx-2.8/wx/defs.h:521,
                 von /usr/local/include/wx-2.8/wx/wxprec.h:13,
                 von ./wx_pch.h:14,
                 von <Kommandozeile>:0:
/usr/include/assert.h:39:42: Fehler: fehlender binärer Operator vor Token »(«
/usr/include/assert.h:108:42: Fehler: fehlender binärer Operator vor Token »(«
In Datei, eingefügt von /usr/include/libio.h:62,
                 von /usr/include/stdio.h:75,
                 von /usr/local/include/wx-2.8/wx/wxchar.h:21,
                 von /usr/local/include/wx-2.8/wx/debug.h:22,
                 von /usr/local/include/wx-2.8/wx/defs.h:521,
                 von /usr/local/include/wx-2.8/wx/wxprec.h:13,
                 von ./wx_pch.h:14,
                 von <Kommandozeile>:0:
/usr/include/sys/cdefs.h:46:44: Fehler: fehlender binärer Operator vor Token »(«
/usr/include/sys/cdefs.h:50:44: Fehler: fehlender binärer Operator vor Token »(«

  [...]


2) === HiWorld, Debug ===

/usr/include/assert.h|39|Fehler: fehlender binärer Operator vor Token »(«|
/usr/include/assert.h|108|Fehler: fehlender binärer Operator vor Token »(«|
/usr/include/sys/cdefs.h|46|Fehler: fehlender binärer Operator vor Token »(«|

  [...]


3) $ gcc -dD -E HiWorldMain.cpp | grep GNUC_PREREQ
In Datei, eingefügt von /usr/include/wx/defs.h:21,
                 von /usr/include/wx/wxprec.h:13,
                 von wx_pch.h:14,
                 von HiWorldMain.cpp:10:
/usr/include/wx/platform.h:196:22: Fehler: wx/setup.h: No such file or directory
In Datei, eingefügt von /usr/include/wx/platform.h:293,
                 von /usr/include/wx/defs.h:21,
                 von /usr/include/wx/wxprec.h:13,
                 von wx_pch.h:14,
                 von HiWorldMain.cpp:10:
/usr/include/wx/chkconf.h:103:9: Fehler: #error "wxUSE_DYNLIB_CLASS must be defined."
/usr/include/wx/chkconf.h:111:9: Fehler: #error "wxUSE_EXCEPTIONS must be defined."
/usr/include/wx/chkconf.h:119:9: Fehler: #error "wxUSE_FILESYSTEM must be defined."

  [...]

/usr/include/wx/chkconf.h:1765:9: Fehler: #error "wxMessageBox is always needed"
In Datei, eingefügt von /usr/include/wx/wxprec.h:13,
                 von wx_pch.h:14,
                 von HiWorldMain.cpp:10:
/usr/include/wx/defs.h:42:13: Fehler: #error "No Target! You should use wx-config program for compilation flags!"
#define __GNUC_PREREQ(maj,min) ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
In Datei, eingefügt von /usr/include/wx/memory.h:16,
                 von /usr/include/wx/object.h:20,
                 von /usr/include/wx/wx.h:16,
                 von wx_pch.h:21,
                 von HiWorldMain.cpp:10:
/usr/include/wx/string.h:164:4: Fehler: #error "Please define string case-insensitive compare for your OS/compiler"
In Datei, eingefügt von /usr/include/wx/cmndata.h:17,
                 von /usr/include/wx/wx.h:65,
                 von wx_pch.h:21,
                 von HiWorldMain.cpp:10:
/usr/include/wx/encinfo.h:64:6: Fehler: #error "Unsupported toolkit"

- End -

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Please turn on full commandline logging and post what is sent to the compiler:
change "Settings -> Compiler and debugger... -> Global compiler settings -> [the compiler you use] -> Other settings(rightmost tab)" "Compiler logging" to "Full commandline"

And please tell which OS (looks like linux, but which distro), compiler and wxWidgets-version (it's 2.8, but which minor-version) you use.

Offline ascii_moe

  • Multiple posting newcomer
  • *
  • Posts: 13
Hi!

Please find the requested details below:

-------------- Build: Debug in HiWorld ---------------

g++ -I/usr/local/lib/wx/include/gtk2-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread  -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall  -g    -I/usr/include/mysql -I/usr/local/include/mysql++ -I/usr/include/wx  -c /home/tw/workspace_wxwidgets/HiWorld/wx_pch.h -o wx_pch.h.gch/Debug_wx_pch_h_gch


- Ubuntu Hardy Heron 8.04 LTS (amd64)
- Compiler: g++ (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
- wxWidgets-Version: 2.8.10.1-0

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
If I see it right, you use self-compiled (ansi-)version of wxwidgets.
Is there any cause not to use unicode and the prebuild-binaries ?

How did you configure wxwidgets before compiling ?

Offline ascii_moe

  • Multiple posting newcomer
  • *
  • Posts: 13
No, I don't use a self-compiled version (as far as I know).
I installed wxWidgets the way I found on http://wiki.wxwidgets.org/Installing_and_configuring_under_Ubuntu .

Since I am new to wxWidgets, was that wrong?
What "unicode and prebuild-binaries" do you mean?

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
I don't think official packages install in /usr/local (but I might be wrong, because I do not use ubuntu).
And you use ansi-libraries.
You should either use the wxwidgets-packages that are shipped with ubuntu ( I don't know if 2.8 was in 8.04 or came later) or the packages from wxwidgets.org as described in the wiki-article (http://wiki.wxwidgets.org/Installing_and_configuring_under_Ubuntu#Using_a_other_packages).

What's the output of
Code
wx-config --list
?

Offline ascii_moe

  • Multiple posting newcomer
  • *
  • Posts: 13
Hm, the way in "Using a other packages" is how I did it. That's what I meant in the previous posting.

wx-config --list says:

Default config is gtk2-ansi-release-2.8
Default config will be used for output

But as I mentioned in my originating posting, the really weird thing ist, that until yesterday compiling worked perfect.
So it seems not to be a general problem...?

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Hm, the way in "Using a other packages" is how I did it. That's what I meant in the previous posting.

wx-config --list says:

Default config is gtk2-ansi-release-2.8
Default config will be used for output

But as I mentioned in my originating posting, the really weird thing ist, that until yesterday compiling worked perfect.
So it seems not to be a general problem...?

The wxwidgets-packages of are unicode-packages not ansi-ones, so you must have self-compiled packages or other binaries installed.
Did you also install wx-common from wxwidgets.org ?
If not you should do that.

Offline ascii_moe

  • Multiple posting newcomer
  • *
  • Posts: 13
I've just installed it:

Hole:1 http://apt.wxwidgets.org hardy-wx/main wx-common 2.8.10.1-0 [63,5kB]

But the error still persists. (I've tried it with the existing project and created a new one).

This situation really seems to be hopeless.
It's a pity, because I just started to like wxWidgets/Code::Blocks (instead of using QT)...


Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
I've just installed it:

Hole:1 http://apt.wxwidgets.org hardy-wx/main wx-common 2.8.10.1-0 [63,5kB]

But the error still persists. (I've tried it with the existing project and created a new one).

This situation really seems to be hopeless.
It's a pity, because I just started to like wxWidgets/Code::Blocks (instead of using QT)...


What does wx-config --list output now ?

Offline ascii_moe

  • Multiple posting newcomer
  • *
  • Posts: 13
Still the same:

wx-config --list

Default config is gtk2-ansi-release-2.8
Default config will be used for output

What should the output be now?

Offline ascii_moe

  • Multiple posting newcomer
  • *
  • Posts: 13
Hi Jens,

it looks like I solved this issue (even if I don't know what the reason for this fault was):
 
I simply removed the current Code::Blocks installation and reinstalled it.
Now everything works fine, again!

In detail, that's what I did:

1. Check the currently installed packages:

$ dpkg -l | grep blocks
ii  codeblocks                                 8.02                                                       Code::Blocks integrated development environm
ii  codeblocks-contrib                         8.02                                                       Contrib plugins for Code::Blocks IDE
ii  codeblocks-dbg                             8.02                                                       Code::Blocks debugging libraries
ii  codeblocks-dev                             8.02                                                       Code::Blocks development files (SDK)
ii  libcodeblocks0                             8.02                                                       Code::Blocks shared library

2. Remove this packages:

$ sudo apt-get remove codeblocks   (This removes  codeblocks, codeblocks-contrib and codeblocks-dbg.)
$ sudo apt-get remove codeblocks-dev
$ sudo apt-get remove libcodeblocks0

3. Check again:

$ dpkg -l | grep blocks
rc  codeblocks                                 8.02                                                       Code::Blocks integrated development environm
rc  libcodeblocks0                             8.02                                                       Code::Blocks shared library

4. Purge remaining packages:

$ sudo dpkg --purge codeblocks
$ sudo dpkg --purge libcodeblocks0

5. Deleting the ".codeblocks" directory in my home directory:

$ rm -rf ~/.codeblocks

6. Reinstall all *.deb packages:

codeblocks_8.02_amd64.deb
codeblocks-contrib_8.02_amd64.deb
codeblocks-dbg_8.02_amd64.deb
codeblocks-dev_8.02_amd64.deb
libcodeblocks0_8.02_amd64.deb
libwxsmithlib0_8.02_amd64.deb
libwxsmithlib0-dev_8.02_amd64.deb

$ sudo dpkg -i *deb

7. Check the reinstalled packages:

$ dpkg -l | grep blocks
ii  codeblocks                                 8.02                                                       Code::Blocks integrated development environm
ii  codeblocks-contrib                         8.02                                                       Contrib plugins for Code::Blocks IDE
ii  codeblocks-dbg                             8.02                                                       Code::Blocks debugging libraries
ii  codeblocks-dev                             8.02                                                       Code::Blocks development files (SDK)
ii  libcodeblocks0                             8.02                                                       Code::Blocks shared library

That's it!

Since then everything went back to normal (creating and compiling new projects, compiling old projects, etc.).
I really don't know what caused this strange behaviour before. Maybe some config file(s) of the old installation have been corrupted?

Nonetheless, many thanks for your help! (I hope that this fault won't occur again... ;-) )


Regards,
Thomas

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Most likely you had wrong settings in the global compiler settings under "Settings -> Compiler and debugger -> Global compiler settings".
These settings are stored in C::B's main conf-file and can mess up your projects.
In this place only settings that really (really !!) should belong to each and any project of the specified compiler should be made.

Offline ascii_moe

  • Multiple posting newcomer
  • *
  • Posts: 13
Can you tell me which one the main config file is? I could not find it, yet.
Maybe it would help, only to delete/reset this file and start with a new configuration, instead of a reinstallation?

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Can you tell me which one the main config file is? I could not find it, yet.
Maybe it would help, only to delete/reset this file and start with a new configuration, instead of a reinstallation?
~/.codeblocks/default.conf