On 31/01/2008, Jan Dubois <jand@activestate.com> wrote: > On Wed, 30 Jan 2008, Robert May wrote: > > So, in the meantime, can anyone suggest a mechanism for testing > > whether the perl that is running my Makefile.PL was compiled with a > > Microsoft compiler, given that if gcc is being used the Config.pm > > values will already have been re-set (with ExtUtils::FakeConfig, > > ActivePerl::Config, or similar). > > > > I can't just blindly add -mms-bitfields' if the compiler is gcc, as > > that would break compatibility with gcc-built perls (Strawberry perl > > ...), and I don't only want to find ActiveState Perl builds - and I > > need it to work back to 5.6.1 > > > > Or am I stuck with putting a big warning in the README (which won't > > stop the bug reports). > > I don't understand why you need to do this at all; you should just > rely on the $Config{ccflags} value. > > Or are you just creating a workaround for the already released > ActivePerl 1001/1002? In that case you can just explicitly > test for it: That's it exactly - I'm on the verge of making a 5.10 compatible release, and don't want it to fail immediately. > if (defined &Win32::BuildNumber) { > } But won't Strawberry Perl have this too? Are you saying that Win32::BuildNumber() is an ActivePerl only thing? If so, then I think this is sufficient for me. > use Config qw(%Config); > my $cc = $Config{cc}; > $cc = "cl" if defined %ActivePerl::Config::; But that won't catch someone who built Perl from the official sources with an MSVC compiler. > Maybe the most general solution would be: > > my $cc; > for my $file (qw(Config_heavy.pl Config.pm)) { > my $fullname = "$Config{privlib}/$file"; > open(my $fh, "<", $fullname) or die "Can't read $fullname: $!\n"; > while (<$fh>) { > $cc = $1, last if /^cc='(.*)'/; > } > last if defined $cc; > } I actually just wrote this: #!perl -w use strict; use warnings; use Config; print +(is_msvc() ? '' : 'NOT '), "MSVC\n"; sub is_msvc { require Config; my $file=$INC{'Config.pm'}; for ('Config.pm', 'config_heavy.pl') { $file =~ s/Config.pm$/$_/; open (my $fh, '<', $file) or next; while (my $l = <$fh>) { next unless $l =~ /^cc=/; # File closed by $fh going out of scope return $l =~ 'cl'; } close($fh); } return 0; } __END__ Yours is much more elegant though. > This of course will still fail if someone builds with VC++ and then > manually patches Config_heavy.pl instead of overriding it > programmatically, but those people should be on their own anyways. :) Indeed :-) Many thanks, Rob.Thread Previous | Thread Next