Results 1 to 5 of 5

Thread: Mixing C++ and C Code; the define __cplusplus

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2013
    Posts
    29
    Thanks
    4
    Thanked 4 Times in 2 Posts

    Question Mixing C++ and C Code; the define __cplusplus

    Hi,

    I’m working on a project which is mixing C++ and C code. I’m now facing the problem that the C code uses #pragma instructions the compiler does not understand. I want to hide those using #ifndef __cplusplus but this define is only available when compiling .cpp files. While .c files are compiled this define is not set since the C compiler is being used.

    Any ideas how I can set this define for the C compiler manually without interfeering with the C++ complier?

    Using

    Qt Code:
    1. DEFINES += "define"
    To copy to clipboard, switch view to plain text mode 

    within the .pro file will result in errors since the C++ compiler also defines this for himself.


    Using:
    Win7 64bit
    Qt 5.3.2
    MinGW, GCC 4.8.2

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Mixing C++ and C Code; the define __cplusplus

    That sounds a bit contradictory.

    The C compiler is being used for .c files, but those .c files contain #pragma instructions that the C compiler does not understand?
    Why do these files then have these instructions?

    Maybe you can post some simple example?

    Cheers,
    _

Similar Threads

  1. mixing qt and mfc
    By marco.stanzani in forum Qt Programming
    Replies: 4
    Last Post: 30th December 2012, 17:30
  2. Mixing Qt and c
    By Aladin in forum General Programming
    Replies: 8
    Last Post: 28th March 2011, 14:29
  3. __cplusplus undefined on Symbian
    By bender86 in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 23rd December 2010, 19:43
  4. Mixing MFC and Qt
    By Lele in forum Qt Programming
    Replies: 1
    Last Post: 11th May 2006, 14:55
  5. Mixing C and Qt
    By forloRn_ in forum Qt Programming
    Replies: 6
    Last Post: 21st February 2006, 00:56

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.