Keep getting " expected initializer before ':' when declaring dll
-
I keep getting some invented errors by the compiler
" expected initializer before ':' token class EXPORT Color_Class : public QColor"I have no clue why this thing doesn't work, i had this error before so i added into the project DEFINES += CL_LIB_LIBRARY
This is the macro, which i put the export/import macro
#define EXPORT CL_LIBSHARED_EXPORT#pragma once #include <QtCore/qglobal.h> #if defined(CL_LIB_LIBRARY) # define CL_LIBSHARED_EXPORT Q_DECL_EXPORT #else # define CL_LIBSHARED_EXPORT Q_DECL_IMPORT #endif
Here the error occurs "class EXPORT Color_Class : public QColor"
The error occurs with few clasess, but this one is the first, i have like 300 clasess, and none of them has the same errors.. I tried to look it up since it should be a bassic error, but none, just whatever i do, same errors occur over and over, just some random invention to waste peoples time.. -
@Loc888 said in Keep getting " expected initializer before ':' when declaring dll:
CL_LIBSHARED_EXPORT
This should be used, not an extra macro
class CL_LIBSHARED_EXPORT Color_Class : public QColor
When you compile your lib you have to add "DEFINES += CL_LIB_LIBRARY" to your pro file, when you use it, this define must not be set.
btw: why do you need to derive from QColor?
-
@Christian-Ehrlicher It doesn't change anything, i tried to do it the last day, but still it doesn't work, even if i remove the define and change it to CL_LIBSHARED_EXPORT.
That EXPORT is a macro to another macro, so it must works, and also it worked for more then half year..
What is the most weird, is if i make it an empty macro so:
#define EXPORT class EXPORT Color_Class : public QColor
the error will still be there....
BUT if i make a new macro
#define ABCD class ABCD Color_Class : public QColor
Then at that point the error disapear, you tell me what is even this thing...
I still have 8 other errors which are:variable 'EXPORT Color_Sets' has initializer but incomplete type
struct EXPORT Color_Sets
---------------^~~~~~~~~~~~~~~~~~expected primary-expression before 'public'
public:
-^~~~~~expected '}' before 'public'
expected ',' or ';' before 'public'
'Color_Class ' does not name a type;
-----Color_Class max;
-----^~~~~~~~~~expected unqualified-id before 'public'
public:
-^~~~~~non-member function 'QString min_to_text()' cannot have cv-qualifier
-----QString min_to_text() const;
^~~~~non-member function 'QString max_to_text()' cannot have cv-qualifier
-----QString max_to_text() const;
^~~~~expected declaration before '}' token
--};
^I have trully no clue what is this thing, i can compile the dll without any problems, so it's not a problem of some missing "}" or so... And the fact that same stuff occurs with an empty macro just speaks for it's self, that something buggy is going on.
-
I found the problem... It was because i had 2 .hpp named the same way, one was with some other macros i used to code, and the second one was with the export macro alone..
They had both the same paths, so in the dll project it was let's say src/macros/defines.hpp, and in the app project where i import the dll it was the same, but i don't understand why when i was clicking on it, it was reffering me to the valid file which i wanted to use.
Also, it worked for half a year, so i didn't bother to change it, probably it worked because the files didn't come in conflict, but since i changed a lot of paths in the dll project, it stopped working, and that's why i got the weird errors, the hpp was set to pragma once and the wrong file was applied, so the compiled treated it as some invalid syntax letters, still the macro in the editor was looking like it was applied, that's what fooled me.