User forums > General (but related to Code::Blocks)

__attribute__ Not Recognized

(1/4) > >>

spflanze:
There is this compilation error in my project. It uses wxWidgets version 3.0.3, and is compiled by GCC in Ubuntu 8.04.


--- Code: ---/opt/wx/3.0/include/wx-3.0/wx/dlimpexp.h|20|error: expected class-name before ‘__attribute__’|
--- End code ---

This error appears on the second of these two lines in the file dlimpexp.h:


--- Code: ---#    define WXEXPORT __attribute__ ((visibility("default")))
#    define WXIMPORT __attribute__ ((visibility("default")))
--- End code ---

This error means, as I understand it, that the "__attribute__" token is not recognized as a GCC attribute, but instead should be preceded with a class name to define what it is. Why it is that  __attribute__ is undefined in the second line above, and seems to be defined in the second is a mystery to me. Yet the second line above is line number 20 in dlimpexp.h, and is where the error is indicated.

I also can't figure why there would be an error such as this in a macro definition, which is supposed simply replace every instance of "WXIMPORT" in the source code with what follows in its line.

This file is part of the wxWidgets 3.0.3 package I compiled on my computer.

BlueHazzard:
We give no support for compiler or wxWidgets related question in this forum, because codeblocks is not a compiler...

spflanze:
After looking at the other error message lines I find the error is not in line 20 of dlimpexp.h where the macro is defined. It is instead everywhere this macro is expanded elsewhere in code. These two macros are defined only if the WXUSINGDLL is defined, the IDE code edtor's highlighting shows it is defined. But I am not not able to find where.  Right clicking and selecting "Find declaration" does not find it. A project wide search for "WXUSINGDLL" does not find it.

It has to be defined in the Code::Blocks IDE somewhere. But I have not been able to find it. Where is this defined?

sodev:
It gets defined by

--- Code: ---wx-config --cflags
--- End code ---
because you use wxWidgets as shared library :).

Apparently you had this before https://forums.wxwidgets.org/viewtopic.php?t=44808, how was it solved back then? Most probably a compiler configuration difference, you compile your application with different, incompatible settings than wxWidgets.


--- Quote from: spflanze on February 12, 2019, 05:40:20 am ---There is this compilation error in my project. It uses wxWidgets version 3.0.3, and is compiled by GCC in Ubuntu 8.04.

--- End quote ---
In your other thread you were using Ubuntu 18.04, if this is not a typo, it might be that the ancient GCC of Ubuntu 8.04 indeed does not understand __attribute__ ;D

spflanze:
It is Ubuntu 18.04.

I do not recall how I solved this earlier.

This project is migrated from Windows 7 because I need Valgrind. This project was transferred from Windows 7 to Ubuntu. I suspect that is trouble. I have created a new project in Ubuntu, and transferred all the files into the new project. But this did not solve the compilation problem I opened this thread for.

Given these errors, I think a shared library is also trouble. I am going to try static wxWidgets.

Navigation

[0] Message Index

[#] Next page

Go to full version