Hi.
BaseExport and similar things are confusing my new QtCreator.
Happens to just about every header file in FreeCAD.
Interestingly, in old Qt Creator, it wasn't much of a problem: it would just underline them, saying "skipping identifier BaseExport" or something.
Is there an easy fix for this? I tried adding add_definitions(-DBaseExport= ) to CMakeLists.txt, that fixed the parsing problem but created build errors.
BaseExport causing parse errors in Qt Creator
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: BaseExport causing parse errors in Qt Creator
temporarily adding #include <FCConfig.h> to the top of the file makes the parser happy. Fine, as long as I don't forget to clean that out when committing.
Re: BaseExport causing parse errors in Qt Creator
I remember vaguely that I had such a problem before. The thing was that the precompiled.h files, which define the macros, use some freecad specific defines to guard the macro definitions. When those defines are not known to the IDE it does not find the definitions. For me it helped to change the IDE settings to set the correct "define"
Re: BaseExport causing parse errors in Qt Creator
QtCreator provides a lot of plugins and for some years it uses the clang compiler to detect syntax errors and the like. If am not not totally wrong then the plugin name is ClangCodeModel which I had to disable to get rid of the warnings. Maybe you did this too with your old version and thus you didn't see all the warnings.Interestingly, in old Qt Creator, it wasn't much of a problem: it would just underline them, saying "skipping identifier BaseExport" or something.
I haven't found one when I searched for a solution.Is there an easy fix for this? I tried adding add_definitions(-DBaseExport= ) to CMakeLists.txt, that fixed the parsing problem but created build errors.
FYI, the macros BaseExport, AppExport, GuiExport, ... are needed for Windows because when creating a dll you must tell the linker which symbols must be exported. For compilers on Windows the macro expands to __declspec(dllexport) for the target that creates a .dll and __declspec(dllimport) when a target uses an existing library.
So, you mustn't simply add a definition to the CMakeLists.txt file because you will mess up the definitions inside the source code.
Re: BaseExport causing parse errors in Qt Creator
Here is a way to suppress the clang error messages about the export macros:
https://doc.qt.io/qtcreator/creator-pro ... ng-defines
You follow the steps to import an existing project and call it e.g. FreeCAD. This will create the file FreeCAD.config and there you can add the lines:
I wonder where there is a way to also tell QtCreator's clang code model to ignore the export macro when loading it as a regular project.
https://doc.qt.io/qtcreator/creator-pro ... ng-defines
You follow the steps to import an existing project and call it e.g. FreeCAD. This will create the file FreeCAD.config and there you can add the lines:
Code: Select all
#define BaseExport
#define AppExport
#define GuiExport
...