----- Original Message ----- From: "David Oswald" <daosw...@gmail.com>
To: <inline@perl.org>
Sent: Sunday, December 18, 2011 10:27 AM
Subject: API question: Determining a compiler's version number.


Does the Inline ILSM object (or some other part of the API) contain
the version number of the compiler being used to compile Inline::C or
Inline::CPP code?

No - afaik.

The Inline::CPP Makefile.PL seems to be doing the job of identifying the C++ compiler quite well. I think your best bet is to then have that compiler tell you whether it has the 'iostream' header present:

eval {system, $cc_compiler, '-o', 'test.exe', 'test.cpp';};
if($@) {  # assume no iosteam, assume iostream.h}
else { # iostrream is present }

test.cpp should look like:

#include <iostream>
int main(void) {
returm 0;
}

test.cpp should *not* ship with the source, but should be written by the Makefile.PL specifically for the test, and unlink()ed (along with 'try.exe') after the test has been conducted.

You may also want to take steps to hide the output of the system command - by redirecting stderr to the null device. (The portable way to do that is to redirect to $File::Spec::devnull.) Just appending a '2>nul' to that system command doesn't work for me on Windows (argument is rejected), so you'd probably need to redirect STDERR to the null device, then redirect it back after the test has been done.

The good thing about redirecting STDERR is that you don't get a noisy build containing error messages. The negative side to redirecting STDERR is that you might miss important messages when something fails for a reason other than the expected reason. (You probably also want to know what's in $@ when the test build fails - just so you can be sure the test build failed because iostream was not found, and not for some other reason.)

Are there any perl extensions that use iostream in their source code ? If so, do any of them take any measures to cater for this problem ?

Cheers,
Rob

Reply via email to