[SOLVED]How to include a global architecture header file at the top of each C file
-
Do you have a space between MY_Q_ARCHITECTURE_H_FILE and = ?
-
Yes, I pasted from yours, which has it. I tried to remove it, same problem.
-
Could you try with a dummy main.cpp ?
@
#include MY_Q_ARCHITECTURE_H_FILE
int main(int argc, char *argv[])
{
return 0;
}
@I just tested it (with qstring.h) and it works
-
Have now tried that code in my main.c (not cpp). Same problem:
D:\Product\AutroKeeper_Sim\Qt\src\autrokeeper_Qt_plainC\main.c:2: error: #include expects "FILENAME" or <FILENAME>
I have compiled along the line. So, maybe there's a problem with my make file? Here is an excerpt:
@
TEMPLATE = appCONFIG += console
CONFIG -= app_bundle
CONFIG -= qtSOURCES += main.c
.....
INCLUDEPATH += ...ARCHITECTURE_FILE = Q_Architecture.h
ARCHITECTURE_FILE_STR = '"$${ARCHITECTURE_FILE}"'
DEFINES += MY_Q_ARCHITECTURE_H_FILE ="$${ARCHITECTURE_FILE_STR}"HEADERS +=
...@
By the way, what's this "with qstring.h".....?
-
You are missing almost all of the backslashes. They are all needed to escape the quotes properly
-
Still does not work. Hmm.. And I now use exactly this (which might come out wrong in the mail, see bottom):
@
ARCHITECTURE_FILE = Q_Architecture.h
ARCHITECTURE_FILE_STR = '\"$${ARCHITECTURE_FILE}\"'
DEFINES += MY_Q_ARCHITECTURE_H_FILE ="$${ARCHITECTURE_FILE_STR}"
@So what's this "qstring.h" stuff? Didn't think qmake accepted any external defs? Hmm..
By the way, the Qt forum should fix their forum-to-mail sw. The extra backslashes got lost there. In my Outlook on XP it looks like this, from which I innocently pasted:-)
@
ARCHITECTURE_FILE = Q_Architecture.h
ARCHITECTURE_FILE_STR = '"$${ARCHITECTURE_FILE}"'
DEFINES += MY_Q_ARCHITECTURE_H_FILE ="$${ARCHITECTURE_FILE_STR}"
@ -
I meant I use qstring.h rather than Q_Architecture.h for my test to ensure that everything was working.
After the changes, did you rebuild the project from scratch ?
-
Well no, not really. If I do, I now get
@<command-line>:0: error: macro names must be identifiers
File not found: <command-line>@Rebuilding I get
@
The Makefile.Release has changed outside Qt Creator. Do you want to reload it?
@Show details then shows:
@
D:\Product\AutroKeeper_Sim\Qt\src\build-autrokeeper_Qt_plainC-Desktop_Qt_5_1_0_MinGW_32bit-Release\Makefile.Release
@Does this have any significance? My .pro file is the one that's in the project in the Creator. I do see that it's used, since I am able to get parse errors.
Not blank any more, but not in goal either. Thanks for your patience!
-
I think I'm giving this up! I've also tried to use the environment.
I have a feeling my first encounter with Qt hit the wall.
I'll introduce another indirection and do a non-fuzz include at the top of each file, to a primary include file that again includes my actual architecture file.
Is it too early to give up? I've also asked people here.
Samuel, since you are in CH and since it's Friday: http://www.teigfam.net/oyvind/home/models/046-sbb-ae-3_6-ii-h0-scale/
-
Very strange... I wonder If it's mingw related but I doubt...
Did you try both from QtCreator and command line ? (meaning deleting the content of the shadow build directory)
Nice link :)
-
I,ve tried both editing in the .pro file and in the qmake additional arguments, and tried read from the envirnoment ("all" permutations), and have tried to clean all and not, and I'm still at square one. That might answer your question..
Even if I do make an extra indirection file, which of course will work - it would be interesting to be informed of a solution to this thread.
I will be out of reach until 29th. Thank you!
Øyvind
-
I ended up using an indirect file instead of trying to define that file in the IDE. Now I branch off in that file to different architecture files.
GCC did not seem to allow what IAR did, which allows file name including quotes in the IDE, to pass over to user code, quotes and all.
Thank you!
-
You welcome !
Since you got it working, please update the thread's title to solved so other forum users may know a solution has been found :)
-
Guess, what, I looked for it before I sent the last message, but even when you have told me there is one I cannot see any such button.. (Safari on XP)
-
No button for that... You have to edit your first post and modify the title :)