Why this results in Error: Syntax error in input(3).

"[email protected]" <[email protected]> Fri, 31 Dec 2021 08:40:42 +0000
Newsgroups gmane.comp.programming.swig
Message-ID <[email protected]>
Hi,

in this file:

https://github.com/nyholku/swig-experiments/blob/master/Patched_Standard_Handle.hxx

if I uncomment lines 216-218 and delete line 219, ie if I change:

#if 1

to (as it was in the original un patched file):

#if (defined(__clang__)) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1300) || \
    (defined(_MSC_VER) && _MSC_VER >= 1800) || \
    (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))


I get

../Patched_Standard_Handle.hxx:229: Error: Syntax error in input(3).

why SWIG chokes on that?

This is even more weird to me because in lines 240-242 exactly same #if works (AFAIU).

The whole problematic #if/#else#endif section from lines 216 to 235 is here for reference:

//#if (defined(__clang__)) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1300) || \
//    (defined(_MSC_VER) && _MSC_VER >= 1800) || \
//    (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
#if 1

    //! Conversion to bool for use in conditional expressions
    explicit operator bool () const
    {
      return entity != nullptr;
    }

#else /* fallback version for compilers not supporting explicit conversion operators (VC10, VC11, GCC below 4.5) */

    //! Conversion to bool-compatible type for use in conditional expressions
    operator Standard_Transient* handle::* () const
    {
      return entity ? &handle::entity : 0;
    }

#endif

wbr Kusti