ingydotnet / inline-c-pm

10 stars 19 forks source link

Fix Include Dir Behavior, Remove Test-For-Errors, Replace Fake stdio.h With time.h To Avoid Microsoft Compiler Errors #81

Closed wbraswell closed 5 years ago

wbraswell commented 5 years ago

@sisyphus Per your request, I have deleted the fake "stdio.h" file which was causing wholesale problems with Microsoft compilers, as well as the old "test/32include_dirs_double_quotes_bad.t" which was checking for error messages.

(I renamed "test/33include_dirs_double_quotes_good.t" to "test/32include_dirs_double_quotes.t" for test numbering uniformity.)

Meanwhile, "test/31include_dirs_angle_brackets.t" needs to have SOME fake file named the same as one of the C standard library files, in order to make sure it does NOT include said fake file. I have thus chosen the file "time.h", which I am hoping will avoid the previous "stdio.h" errors in Microsoft.

If "time.h" also causes a conflict with Microsoft compilers automatically including the fake file, then there are a number of other C standard file names from which to choose, although hopefully that won't be necessary: https://en.cppreference.com/w/c/header

sisyphus commented 5 years ago

We might get by with time.h - but it will get included by MS compiler, and therefore needs to be valid C.

I'm thinking that our t/time.h contain just one line of code, plus a newline:

define BUGGER_BUGGER_BUGGER

and that t/31include_dirs_angle_brakcets.t look something like:

Just one test - to verify that t/time.h

does not get included

use warnings; use strict; use Inline C => <<'EOC'; int foo() {

if defined(BUGGER_BUGGER_BUGGER) / t/time.h has been included /

return 0;

elif defined(_TIMEH) / standard time.h has been included /

return 1;

else

return -1; / neither version of time.h has been included /

endif

}

EOC

print "1..1\n"; if(foo() == 1) { print "ok 1\n" } elsif(foo() == -1) { warn "\ntime.h not included - test is inconclusive\n"; print "ok 1\n"; } else { print "not ok 1\n"; } END

It compiles with my Microsoft compiler, but fails as expected. I guess that since we expect that test to fail with MS compilers, we should modify the diagnosis of that result such that it becomes a "pass". Or maybe just skip that test script altogether when failure is expected.

My main concern is that we might strike a case where some other test script fails because t/time.h got included, but the "real" time.h is needed. Seems a reasonable guess that we won't ... but it's still a guess that would call on yet another release from Tina if it's wrong.

I have other ideas .... none of them are particularly satisfactory. (I need to think about it a bit more.)

I do wish this "FindBin" feature had never been introduced. I don't think that reverting it is an option - but if someone wants to tell me I'm wrong about that, then there will be no argument from me.

Cheers, Rob

On Sun, Jan 27, 2019 at 1:26 PM William N. Braswell, Jr. < notifications@github.com> wrote:

@sisyphus https://github.com/sisyphus Per your request, I have deleted the fake "stdio.h" file which was causing wholesale problems with Microsoft compilers, as well as the old "test/32include_dirs_double_quotes_bad.t" which was checking for error messages.

(I renamed "test/33include_dirs_double_quotes_good.t" to "test/32include_dirs_double_quotes.t" for test numbering uniformity.)

Meanwhile, "test/31include_dirs_angle_brackets.t" needs to have SOME fake file named the same as one of the C standard library files, in order to make sure it does NOT include said fake file. I have thus chosen the file "time.h", which I am hoping will avoid the previous "stdio.h" errors in Microsoft.

If "time.h" also causes a conflict with Microsoft compilers automatically including the fake file, then there are a number of other C standard file names from which to choose, although hopefully that won't be necessary: https://en.cppreference.com/w/c/header

You can view, comment on, or merge this pull request online at:

https://github.com/ingydotnet/inline-c-pm/pull/81 Commit Summary

  • Fix Include Dir Behavior, Remove Test-For-Errors, Replace Fake stdio.h With time.h To Avoid Microsoft Compiler Errors

File Changes

Patch Links:

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ingydotnet/inline-c-pm/pull/81, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEdvDIVY5Pz8QLPTiTlZv2fgl9crQ5Fks5vHQ5agaJpZM4aUf7F .

wbraswell commented 5 years ago

@sisyphus Okay I will implement your proposal, but first can you please tell me if any of the following original C standard library headers will NOT be somehow included by default in the Microsoft compiler?

sisyphus commented 5 years ago

Seems that they're all included by the perl headers.

According to the test I ran, neither _INC_MATH (defined by math.h) nor _INC_TIME (defined by time.h) are defined. Yet, I've verified that both math.h and time.h are being included. The unique symbols defined by the other headers you specified are all defined, so one presumes that those headers have all been included.

On Sun, Jan 27, 2019 at 4:37 PM William N. Braswell, Jr. < notifications@github.com> wrote:

@sisyphus https://github.com/sisyphus Okay I will implement your proposal, but first can you please tell me if any of the following original C standard library headers will NOT be somehow included by default in the Microsoft compiler?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub , or mute the thread .
wbraswell commented 5 years ago

Closing in favor of attempting a "non-polluting" solution as described here: https://github.com/ingydotnet/inline-c-pm/issues/72#issuecomment-461026410