Author Topic: __attribute__ Not Recognized  (Read 161 times)

Offline spflanze

  • Multiple posting newcomer
  • *
  • Posts: 82
__attribute__ Not Recognized
« 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.

Code: [Select]
/opt/wx/3.0/include/wx-3.0/wx/dlimpexp.h|20|error: expected class-name before __attribute__|
This error appears on the second of these two lines in the file dlimpexp.h:

Code: [Select]
#    define WXEXPORT __attribute__ ((visibility("default")))
#    define WXIMPORT __attribute__ ((visibility("default")))

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.
« Last Edit: February 12, 2019, 10:04:33 am by spflanze »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2233
Re: __attribute__ Not Recognized
« Reply #1 on: February 12, 2019, 11:40:18 am »
We give no support for compiler or wxWidgets related question in this forum, because codeblocks is not a compiler...

Offline spflanze

  • Multiple posting newcomer
  • *
  • Posts: 82
Re: __attribute__ Not Recognized
« Reply #2 on: February 13, 2019, 12:58:20 am »
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?

Offline sodev

  • Almost regular
  • **
  • Posts: 206
Re: __attribute__ Not Recognized
« Reply #3 on: February 13, 2019, 01:34:22 am »
It gets defined by
Code: [Select]
wx-config --cflagsbecause 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.

There is this compilation error in my project. It uses wxWidgets version 3.0.3, and is compiled by GCC in Ubuntu 8.04.
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

Offline spflanze

  • Multiple posting newcomer
  • *
  • Posts: 82
Re: __attribute__ Not Recognized
« Reply #4 on: February 13, 2019, 11:06:59 am »
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.


Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2233
Re: __attribute__ Not Recognized
« Reply #5 on: Yesterday at 04:40:09 pm »
beside this being the wrong place to ask this kind of question i do not think that the compiler does not understand the __attribute__ bit, but the bit before the __attribute__ part.... There is some class as return value that is not defined or declared...

Quote
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.
Of course you can not use the same project.... there are tons of defines in the windows project file that are not supported or wrong on linux.
If you have a compiling problem follow this faq:
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F