PIN 3.0 compilation error because of '__value' symbol - c++

I am porting my tool to PIN 3.0 using Visual c++ 2012 because I now have Windows 10. I followed the porting guide provided here
However, I ran into an error:
error C4890: '__value': use of this keyword requires the command line option: /clr:oldSyntax
When turning this /clr:oldSyntax option on, plus adding RTTI availability (/GR instead of /GR-) as otherwise it is not compatible with /clr:oldSyntax, I get more or less the same issue:
error C2059: syntax error: '__value'
this error is located in the file type_trait.h (header file of the PIN 3.0 Library)
#ifdef _STLP_STATIC_CONST_INIT_BUG
static const bool __value;
#else
static const bool __value = sizeof(__test<_Tp>(0)) == sizeof(__select_types::__t1);
#endif
Is this a common issue, and if so is there any workaround ? Or did I missed something in the porting guide ? I understand that the name __value introduced in this PIN 3.0 header is in conclict.

This is apparently a "bug" in visual c++ as reported here
The solution is to add the following preprocessor definition:
/D__value=_value

Related

Q_DECLARE_INTERFACE for plugin creation throws errors all over

Environment:
Framework: Qt 5.12.9
Compiler: MSVC 15.9.28307.1234 (x64)
Debugger: CDB 10.017763.132 (x64)
Standard: C++11
Editor: Qt Creator 4.12.2
OS: Win10 Enterprise 1809
I want to develop an application that can be expanded through plug-ins. Therefore I created a standard library project where I want to define the plug-in interfaces. This library should then be consumed by the main application and its plug-ins.
I read about the Qt plug-in system on the official websites and sought help by duckduckgo-ing, but I'm stuck with these following errors:
vccplugin.h:16:32: error: expected parameter declarator
vccplugin.h:14:23: note: expanded from macro 'VccPlugin_iid'
vccplugin.h:16:32: error: expected ')'
vccplugin.h:14:23: note: expanded from macro 'VccPlugin_iid'
vccplugin.h:16:20: note: to match this '('
vccplugin.h:16:1: error: C++ requires a type specifier for all declarations
Build Issue: C2059: syntax error: 'string'
This is the code:
#ifndef VCCPLUGIN_H
#define VCCPLUGIN_H
#include "VccPluginInterface_global.h"
class VCCPLUGININTERFACE_EXPORT VccPlugin
{
public:
VccPlugin();
~VccPlugin();
void DoeEenTwuk();
};
#define VccPlugin_iid "automation.general.vcc.interface"
Q_DECLARE_INTERFACE(VccPlugin, VccPlugin_iid);
#endif // VCCPLUGIN_H
Also note, I have little experience in both C++ and Qt.
Any help very appreciated,
thanks
I have found the issue. The problem is that the compiler couldn't find the macro, so all I had to add was:
#include <QtPlugin>
Since Q_DECLARE_INTERFACE is defined in QtPlugin. Your example didn't import QtPlugin but was probably imported implicit by another import, probably QMainWindow.
It would have been simpler if I got an error like: "Could not find symbol Q_DECLARE_INTERFACE" if you ask me. Especially since I'm rather blue in this topic.
Thanks for your support #NgocMinhNguyen and others

Where to define _SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS macros?

I am developing TCP/IP program using Boost.Asio but I am getting error :
note: see declaration of 'std::allocator<void>' 1>d:\hardware\libraries\visual studio 2017\x64\include\boost\asio\use_future.hpp(137): error C4996: 'std::allocator<void>': warning STL4009: std::allocator<void> is deprecated in C++17. You can define
_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning.
After reading the error I understood that I have define
_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING
or
_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
I define them once in Configuration Properties -> C/C++ -> General -> Additional #using Directories but error is still persistent.
Then I #defined booth the macros in main file before including any header but still the error persisted.
Then I declared the macro in my per-compiled herder but the error still persisted.
I even tried 2 different boost packages. One installed with vcpkg package manager and one pre-fill binary.
MSVC 14.1 x64
Boost : 1.68 (x64)
Just Turning off "SDL checks" is all you need.
Detail: property page of current project> 'c/c++'>'General'>'SDL checks'
(VS2019, Win10 X64; 2021/01/27)

ISampleGrabber undeclared identifier

I'm trying to execute a code generated by graphEditPlus (using VS2010) but having a trouble with the following line:
CComQIPtr<ISampleGrabber, &IID_ISampleGrabber> pSampleGrabber_isg(pSampleGrabber);
where the errors are:
error C2065: 'ISampleGrabber' : undeclared identifier
error C2065: 'IID_ISampleGrabber' : undeclared identifier
error C2514: 'ATL::CComQIPtr' : class has no constructors
I tried downloading different versions of Windows SDK (V7.1, V6.0A, V5) and set the include / lib paths but still having the same problem!
Is the SampleGrabber still being supported? Mainly, the SampleGrabber is used in my code to grab frames from a video capturing source...
Thanks for your assistance...
Microsoft deprecated Sample Grabber and the entire DES API, however you if you import the type library, or just copy the declarations into your project - the component is still usable except some very latest OS releases (Windows Server 2008?) where it is completely gone and you might need another solution such as building your own from earlier SDK samples.
See ISampleGrabber deprecated: where can I find alternatives? for more information.
See also RenderWmvVideo.cpp with code fragment to copy/paste and re-add the declarations to your project (#pragma section at the top of the file):
#pragma region Windows SDK Tribute, qedit.h
struct __declspec(uuid("0579154a-2b53-4994-b0d0-e773148eff85"))
ISampleGrabberCB : IUnknown
{
...
#pragma endregion

Very Mysterious/Random C++ WDK STL 7 Error: iosfwd(202): error C2144: syntax error

I have the following trivial file named Temp.cpp:
#include <string>
int main() { return 0; }
and I'm trying to compile it with the following command-line in the Windows XP Free Build Environment, using WDK 7.1:
cl.exe /Iinc\api\crt\stl70 /Iinc\crt C:\Temp.cpp
and I'm getting really random errors like:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.207 for 80x86
C:\WinDDK\7600.16385.1\inc\api\crt\stl70\iosfwd(202) :
error C2144: syntax error : 'int' should be preceded by ';'
The error goes away if I use stl60 instead of stl70, but that doesn't solve the problem.
What's the cause of the problem?
Update: I tried uninstalling and installing the WDK again, but nothing changed. :(
Update 2: Okay, apparently the error is screaming out at the header file itself: _SCL_INSECURE_DEPRECATE is the cause. Does anybody know how to turn it off correctly? (If I just comment out the lines, I get a ton more errors regarding a bunch of other macros.)
Found the answer myself, through modifying the headers and guess'n'checking:
I need to have _STL70_ defined.
Which cl.exe are you picking up? If your path happens to have an older (VC6) compiler before the WDK one, you'd expect these errors. VC6 can't compile the STL as shipped with VC7
apparently the error is screaming out at the header file itself: _SCL_INSECURE_DEPRECATE is the cause. Does anybody know how to turn it off correctly?
If you're having problems with _SCL_INSECURE_DEPRECATE, try setting:
/D_SCL_SECURE_NO_DEPRECATE
But given the error message you're seeing it sounds like you're the compiling headers with a a compiler that's older than the headers support (so this might not get you very far anyway).

Dots in Variables? VC9 gives parsing errors when building beecrypt

I want to compile the beecrypt library under VS2008. But several of the below structures produce a syntax error (C2059 syntax error: '.'):
const hashFunction md5 = {
.name = "MD5",
.paramsize = sizeof(md5Param),
.blocksize = 64,
.digestsize = 16,
.reset = (hashFunctionReset) md5Reset,
.update = (hashFunctionUpdate) md5Update,
.digest = (hashFunctionDigest) md5Digest
};
VC++ does not accept the dots in the beginning. If I comment the above, I get Linking errors later (LNK2001 unresolved symbol _md5) - so I guess it has to be uncommented.
What is this structure? For what do I need it? How do I tell VS2008 to compile it?
This type of struct initialization is a feature of C99 (ISO/IEC 9899:1999). It is not valid C++ or C prior to the latest standard.
Visual Studio 2008 only supports C90 (aka C89), so this isn't going to compile.
Edit It looks like BeeCrypt very recently changed to require a C99 compiler which effectively rules out Visual Studio. You other option is to use an older version of BeeCrypt.