Link to home
Start Free TrialLog in
Avatar of BigRat
BigRatFlag for France

asked on

C++ Language error

I'm getting this error :-

error C3688: invalid literal suffix '__FSTREXP'; literal operator or literal operator template 'operator ""__FSTREXP' not found [C:\node-win32ole\build\node_win32ole.vcxproj]


on this section of source :-

  BDISPFUNCDAT("context %s "__FUNCTION__" %s\n", "preset", "start");


(Comes from node-win32ole project)

when I compile it with Visual Studio Community 2015.

What can I put in the solutions file in order to surpress the error (a warning would be acceptable)
Avatar of Zoppo
Zoppo
Flag of Germany image

Hi BigRat,

I found a hint which might help you there the problem was a missing space between "(" and __DATE__.

So you should try it with some spaces before and after __FUNCTION__, i.e.:
BDISPFUNCDAT("context %s " __FUNCTION__ " %s\n", "preset", "start");

Hope this helps,

ZOPPO
Avatar of BigRat

ASKER

Sorry, Zoppe, but it doesn't help. I have already seen that. What would help would be something to turn off this behavior. The string is to be output as is (as far as I an tell).
Hm - I don't think this is simply a behavior which can be turned off.

For any reason the compiler wants to use something names ""__FSTREXP, this is obviously wrong and IMO is caused by a missing space, the question is where it is becaise even obviously it's not the __FUNCTION__ macro which is wrong here, there either must be another line using that __FSTREXP or it is something within the BDISPFUNCDAT macro.

Could you post the definition of this BDISPFUNCDAT macro?

Best regards,

Roman
Have you tried __func__ instead of __FUNCTION__? As Zoppo said, the macro definition would help.
Avatar of BigRat

ASKER

I'm still searching through the mess which is called node-gyp

https://github.com/nodejs/node-gyp

I did change the call to the macro just to see what happens and another language error turns up. Not having used MS C++ since Visual Studio 6.0 (which was probably the best edition) I'm really looking fopr some help in turning off language features. I'm not in a position to hack the node-gyp code nor do I really want to.
BDISPFUNCDAT("context %s "__FUNCTION__" %s\n", "preset", "start");

assume the current function where the statement could be found is 'some_function', then the statement would resolve to

BDISPFUNCDAT("context preset ""some_function""start\n");

Open in new window


quoted strings in the same line were concatenated- so the full string is

"context preset some_function start\n"

Open in new window


what looks like a (Java?) script command for to be written to a script file with an ending linefeed.

BDISPFUNCDAT is a macro or a function which  takes the string as argument. the macro/function is responsible for the error message by using  __FSTREXP macro. __FSTREXP should turn a char literal to a wide-char literal, adding prefix L:


__FSTREX("xyz")            ==>      L"xyz"

if this doesn't work with vs2015 you may define the following macro yourself:

#define __FSTREX(s) L##s

and put it at the top of the file that doesn't compile.

Sara
Avatar of BigRat

ASKER

I'm sorry, Sara, but the source is not under my control. The 2015 version of Visual Studio seems to contains some new features which go under the name C++11 (or something similar). I would like to be able to turn them off. The other alternative might be to try and find a Visual Studio 2013 version which I might download.

Reading around it seems that there is a special preprocessor for C++ which is responslble for this behaviour.
the source is not under my control.
you could try to add the definition of __FSTREX to the preprocessor settings of your project configuration. go to  c/c++ - preprocessor page and add

;__FSTREX(s)=L##s

to the existing preprocessor definitions.

alternatively, you could replace the source that doesn't compile by a copy where you added the preprocessor statement at top. if the source has included stdafx.h as first include statement, you can let the source as it is and add the macro definition to stdafx.h of your project.

last (or first) choice, you may ask in the forum for node-win32ole how to get a vs2015 compatible version of the project.

Sara
Avatar of BigRat

ASKER

Well I have tried out some of the suggestions here, but have run into yet another problem :-

AppData\Roaming\npm\node_modules\node-gyp\src\win_delay_load_hook.c(34): error C2373: '__pfnDliNotifyHook2': redefinition; different type modifiers [C:\node-win32ole\build\node_win32ole.vcxproj]
  C:\Program Files\Microsoft Visual Studio 14.0\VC\include\delayimp.h(134): note: see declaration of '__pfnDliNotifyHook2'

It seems that this is something else which has changed sine Visual Studion 2013 or earlier.

Back to my question: Is there any switch to turn these features off?
Hi BigRat,

I'm still sure the problem is the missing space between " and _ in the definition of BDISPFUNCDAT. If you can't change the definition (or i.e. get a corrected version from where you have the code) and if you need to use it there's no way to do it with the compiler shipped with VS 2015. The way the macros are processed follows (at least mostly) the C++ specifications and as far as I can see there's no compiler option to turn off the new language feature for which this is used.

So it seems all you can do is installing an older Visual Studio, best would be to find the most recent version which compiles this without error, probably that's VS 2013, maybe not, you'll have to try.

You can download VS 2013 Comunity at https://www.visualstudio.com/news/vs2013-community-vs.aspx - for older versions try to google for it, should be easy to fine.

One thing to mention: As soon as you have an older VS installed you can use its compilers even from within VS 2015 - to do so you can select another compiler (Platform Toolset) in the project's properties.

Best regards,

ZOPPO
error C2373: '__pfnDliNotifyHook2': redefinition; different type modifiers [C:\node-win32ole\build\node_win32ole.vcxproj]
these kind of errors are normal when trying to include older 3rd-party sources with a newer compiler version since some of the basic headers may have changed.

generally, you have two choices: you may ask the vendor or developer whether they have a new version of their product. if it is a known product, it is a good probability that they can help you with this.

another choice is to locate the wrong definitions in the header files and add some constraints such that the newer definition could not apply. if for example the newer definition of __pfnDliNotifyHook2 would look like

#ifndef XXXXX
....
#define __pfnDliNotifyHook2 void (DliNotifyHook2 *)(void)
....
#endif 

Open in new window


you could add XXXXX to the preprocessor definitions of your project and the error could/should be solved. however, doing so may cause a lot of other errors which cannot be solved same way or without deep knowledge of the old and new definitions.

so, if the new header hasn't explicitly a version dependent constraint which you easily could switch on and off, you better go the first choice.

Sara
Avatar of BigRat

ASKER

We are getting nowhere with this and I'm getting deeper and deeper into an area of which I have no experience.

The question was is there a switch in Visual Studio 2015 to turn all this off and the answer appears to be no. So if no-one objects, I'll close this question with the comment that hinted that there was no such switch. At least that negative result will PAQ/FAQ for anybody else who runs into this problem.
is there a switch in Visual Studio 2015 to turn all this off

i heard of the following option (while not yet tried it myself):

if you open first time a project of an older vs version in VS2015, you will be asked if you want to convert it to a vs2015 project. if you say no and still have a working compiler whcih fits to the project file, vs2015 die would use the compiler, linker and environment of the older visual studio for build.

i don't know if you have the needed vs version, but if yes, it probably is worth a try.

Sara
Avatar of BigRat

ASKER

Well before I close, I'll try it out. Thanks.
Avatar of BigRat

ASKER

I tried that out without sucesss. So the answer is there is no switch to switch off the behavior, so I'll have to try another approach, and since my RatScript can handle ActiveX objects I'll just have to re-program it a bit in order that it can run as a service.

Thanks for the effort, it is a pity there wasn't a solution. But the question only asked about the switch.
I had the same problem with this project as BigRat. I tried to built using Visual Studio Community 2015. As Zoppo advised, I added spaces before and after __FUNCTION__ on lines 15 and 25 of force_gc_extension.cc  file. And it HELPED! The node-win32ole project is not mantained more than 4 years. So the sln file was outdated - I had to convert it before and fix force_gc_extension.cc file.
Avatar of BigRat

ASKER

I shall get back to this question later in the week when I finish my current assignment and try out the latest suggestion.
Avatar of BigRat

ASKER

Thanks, Sarabande, I'd forgotten this one, which incidentally I still can't get to work, but I think the problem lies with me. I'll let the question be automatically closed.
I'm slightly confused by the suggested closure. Didn't the OP say they'd already tried that and it didn't help? After reading this with my CV hat on, I can't honestly say there's a definitive answer here worth PAQing. I'd be inclined to delete, unless the OP can provide more feedback.
Avatar of BigRat

ASKER

@evilrix: that is a fair objection. I had already tried your suggestion before I posted the question here. I can't say where I found that suggestion, since it was on another forum. But I have still not got winole for node to compile property with Visual Studio 2015. Maybe somebody ought to post their solution file which works. Every time there is a new version of Visual Studio there is a long list of "help me"s on the node-gyp site and lots of people struggling to get SOMETHING to work. It is a disaster! In my RatScript interpreter I built ActiveX COM directly in and added the ability to define (rather like node-gyp) a DLL's interface and to create an object instance of it for both (L)unix and Windows.
>> RatScript interpreter
That sounds interesting. Is it an open source project you're working on?
Avatar of BigRat

ASKER

No, it was something I started back in the nineties for a company I used to work for. But what are we going to do with this thread?
Hi,
I'm usinng node-win32ole to automate Excel. Node-win32ole didn't support safe arrays which I needed to insert values into large ranges of cells. So I've implemented it. I can build the module using    
node-gyp configure
node-gyp build 

Open in new window


with no problems

My setup is: Win7, Visual Studio 2015 Express.

I can attach whatever you want, so tell me what should I attach. Will my .sln or .vcxproj help you?
Avatar of BigRat

ASKER

I think the solution file - since I'm also using VS 2015 on Win 7
ASKER CERTIFIED SOLUTION
Avatar of Zbysek Martoch
Zbysek Martoch
Flag of Czechia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BigRat

ASKER

The zip file did it. Thanks!