Fixes for BOOST_SPIRIT_DEFINE [was: Spirit X3 with on_success() calls on VS2015]
Yes, MSVC is terrible, comparatively... but it has a marvelous development environment and great code generation, once you can get it to actually grok your code. :-) I'm going to await feedback from Microsoft on my bug report, before I dig any deeper into possible fixes for the on_success problem.
Oki, so... as mentioned in my previous mail, I'm using my own macro instead of BOOST_SPIRIT_DEFINE() since it doesn't work on VS2015.
The reason for this is twofold; I need to work around VS2015's broken decltype (second parameter), and I need to sometimes delay initialization of my rule definitions by wrapping them in a function.
Spirit x3 unfortunately pretty much forces one to use global variables as rule definitions, which is a pain is your rules have any sort of dependency on another global variable, which is not in the same file. In my case I had global tokens that needed to be initialized before the rules were initialized, and since the initialization order between files is "random", that created a problem for me. The solution: create the rules at first use by initializer functions.
So... Joel, I would like to suggest the following upgrade to the BOOST_SPIRIT_DEFINE_ macro, which solves both my problems (in the case of MSVC only, if you follow naming strictly at least):
This works on MSVC, and it should work on proper compilers too. So... I actually haven't even read how to submit changes, and this isn't even the devel list (I should go join that...). If you need the patch some other way to be able to accept it, let me know... but, how does this look to you? Worth a go? Would be wonderful for me!
From: Joel de Guzman [mailto:[hidden email]]
Sent: Friday, March 18, 2016 02:45
To: [hidden email] Subject: Re: [Spirit-general] Spirit X3 with on_success() calls on VS2015
On 17/03/2016 10:54 PM, Mikael Asplund wrote:
> I seem to have run into a bug in spirit x3 (or more likely in VS2015,
> but there is no workaround in spirit).
> This results in my on_success() not being called on Windows. I'm
> looking into this, but wanted to ask if someone have seen this before
> and is aware of this problem and why it occurs? Maybe someone with more knowledge is this area that can figure it out quickly?
Wow, I applaud your heroic efforts. I wish I can help more but I've given up on this compiler a long time ago. This compiler reminds me of endless days trying to figure out ICEs.