Nick Wellnhofer created CLOWNFISH-53:
----------------------------------------

             Summary: Support MSVC in C mode
                 Key: CLOWNFISH-53
                 URL: https://issues.apache.org/jira/browse/CLOWNFISH-53
             Project: Apache Lucy-Clownfish
          Issue Type: Improvement
          Components: Core
            Reporter: Nick Wellnhofer
            Priority: Minor


MSVC 12 which is part of Visual Studio 2013 has greatly improved support for 
C99. This makes it possible to build Clownfish projects in normal C mode as 
opposed to C++ mode which we traditionally used. I already switched to C mode 
for the Clownfish compiler and runtime.

But there's a problem with projects linking to the Clownfish DLL. [As explained 
here|https://msdn.microsoft.com/en-us/library/twa2aw10.aspx], it's not possible 
to use the address of a global variable imported from a DLL via 
{{__declspec(dllimport)}} in a global initializer. This is only a problem for C 
code. C++ has much fewer restrictions regarding global initializers. We 
currently need this feature for the {{parent}} and {{parent_offset}} fields in 
the class and method spec structs.

I already hit the same problem with MinGW. I was able to circumvent it by 
simply omitting {{__declspec(dllimport)}}. Further investigation showed that 
this works because of the {{--enable-auto-import}} feature of MinGW's linker. 
Unfortunately, this is a GNU-only extension.

I can think of a couple of different solutions.

* Define all spec structs as local variables in a function.
* Initialize the problematic fields in a function.
* Lookup parent classes and parent method offsets by name.




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to