• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Forcing a single source file to compile with different compiler
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Forcing a single source file to compile with different compiler


  • Subject: Re: Forcing a single source file to compile with different compiler
  • From: Mike <email@hidden>
  • Date: Wed, 16 May 2007 11:07:56 -0700

Except that this is a library file used in many projects. If the file's extension is .c then the code won't link in projects that are using C++. Some of my projects need the code in this file for C++-based projects, some others for C-based projects.

In fact, the best solution for a library of files of C routines is to simply "extern C" them in the code and leave the file extension at ".cp". That allows both C and C++ code to be compiled in the same file, but also allows other files that contain only C code to link to the C routines in the .cp file.

Thanks,

Mike

Scott Tooker wrote:
There are two good solutions here:

- By far, the best thing to do is change the file extension on the file to .c. This is the cleanest way to deal with this.

- If for some reason you can't change the file extension on the file itself, bring up the inspector for the file reference and change the filetype. This is better than adding "-x c" since the debugger will also honor the filetype set in the inspector.

Scott

On May 15, 2007, at 11:12 PM, Mike wrote:

I have a Carbon project in XCode 2.4.1. I have a .cp library file but for this project I want just that one file to compile as a C, not a C++ file. Is there a way to force XCode to use the C compiler on just that one file instead of using the C++ compiler?

Thanks,

Mike
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:


This email sent to email@hidden


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Forcing a single source file to compile with different compiler
      • From: "Shawn Erickson" <email@hidden>
    • Re: Forcing a single source file to compile with different compiler
      • From: Rick Altherr <email@hidden>
References: 
 >Forcing a single source file to compile with different compiler (From: Mike <email@hidden>)
 >Re: Forcing a single source file to compile with different compiler (From: Scott Tooker <email@hidden>)

  • Prev by Date: Re: Forcing a single source file to compile with different compiler
  • Next by Date: Re: Forcing a single source file to compile with different compiler
  • Previous by thread: Re: Forcing a single source file to compile with different compiler
  • Next by thread: Re: Forcing a single source file to compile with different compiler
  • Index(es):
    • Date
    • Thread