#defines in .config file are not global



  • I recently created a new Creator project by importing an existing project with a Makefile. I then declared a number of defines in the .config file that was generated together with the rest of the project. The problem is that when I compile my code does not recognize the define statements in the file. I am using the latest QtCreator 2.4.0 from revision b0b0842b03.

    This is what I have in by .config file:
    @
    // ADD PREDEFINED MACROS HERE!
    #define F_CPU 8000000UL
    @

    Thanks for any help on this,
    /Lars



  • #defines are better hosted in a header file that you include in all your source and header files.



  • In general I agree with you. However, in this case I want to use it for project specific defines and macros. As I understand it this is exactly what the .config file is intended for although the defines does not seam to be recognized by the compiler.



  • bq. From "Creator Docs":http://doc.qt.nokia.com/qtcreator-2.4/creator-project-generic.html:"
    The defines are specified in the .config file. The .config file is a regular C++ file, prepended to all your source files when they are parsed.

    I interpret it as if the file is used for parsing in Creator's internal parser (for syntax highlighting etc.). The file is not used as an include file or as list of -D options for your sources during actual compilation.

    As it is a generic project, Qt Creator does not have any clue on how to pass that information to the toolchain.

    To me the file serves for this purpose: You can add defines to the compiler command line using -D options. As Creator is not able to "see" those, you can repeat them in the .config file so that Creator can act correctly on the #ifdefs etc.



  • Thank you for clarifying things to me. Now understand how to use the .config file.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.