How to reliable detect a MacPorts-ported compiler?

Ryan Schmidt ryandesign at
Tue Sep 8 21:08:21 PDT 2015

On Sep 8, 2015, at 10:56 PM, Jeffrey Walton wrote:

>>> Is there a #define so we can detect it in the source code?
>> Not that I'm aware of.
> OK, thanks.
> That's kind of a problem. The problem occurs when a user includes the
> library. We (the library) can get into a good state at build time by
> shell'ing out and detecting MacPorts, and then defining something to
> avoid the code path. But we can't get users of the library in a good
> state because we don't control their make or command line.
> Does MacPorts offer anything in the preprocessor we can key on?

We are not deliberately changing anything about the compiler (aside from fixing bugs, and aside from adding our string to the version string, for which they provide a configure flag so they clearly intend for that to happen), so no, I don't know of any way to detect whether your code is being compiled by a FSF GCC distributed by MacPorts as compared with a FSF GCC distributed by Homebrew as compared with a FSF GCC compiled by a user by hand. Again, I have to ask why you want to do this. What problem are you seeing with FSF GCC compiled with MacPorts that you do not see with FSF GCC compiled on a Mac by some other means? It is not our intention to be different, so if we are different in some important way, maybe we can fix that.

More information about the macports-users mailing list