Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Mixing Objective C and C++11

    General and Desktop
    3
    4
    2091
    Loading More Posts
    • 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.
    • S
      szatmary last edited by

      I am unable to mix objective C and C++11 in a single Qt Project. When I try, I get the error:

      error: invalid argument '-std=c++11' not allowed with 'C/ObjC'

      I can however manually modify the Makefile to remove -std=c++11 and -stdlib=libc++ from QMAKE_COMP_QMAKE_OBJECTIVE_CFLAGS, and it works.
      Is this a bug in qmake? Should qmake not be including these values? Or I am missing something? Is there a way to setup my .pro file to create a working Makefile?

      1 Reply Last reply Reply Quote 0
      • Gianluca
        Gianluca last edited by

        I use a mix of C++ and Obj-C in the Qt project without any problems.
        What I did it's just to add a source file with exentsion .mm in .pro file:
        @
        OBJECTIVE_SOURCES += objectiveSource.mm
        @

        1 Reply Last reply Reply Quote 0
        • S
          szatmary last edited by

          HA! that totally worked. Renaming .m to .mm solved it.

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Hi,

            m -> pure objective-c
            mm -> objective-c++

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 0
            • First post
              Last post