Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. #defines in .config file are not global
Forum Updated to NodeBB v4.3 + New Features

#defines in .config file are not global

Scheduled Pinned Locked Moved Qt Creator and other tools
5 Posts 2 Posters 6.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    laran
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

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

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • L Offline
        L Offline
        laran
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          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.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • L Offline
            L Offline
            laran
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved