WDK (Windows Driver Kit) and VC++ headers problem - visual-c++

I'm trying to read from an USB HID device, I know how to do it in C# using DLLImport hid.dll, but I want to do it from C++, this way I don't have to declare all the structures, etc, and just include the headers files.
So I downloaded the WDK and then when including the headers files and linking the libraries I'm getting a lot of errors:
#include <windows.h>
extern "C" {
#include <hidsdi.h>
}
int main(){
}
Errors (6 out of 163):
Error 1 error C2065: 'PASSIVE_LEVEL' : undeclared identifier c:\winddk\7600.16385.1\inc\api\hidpi.h 302 driver
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\winddk\7600.16385.1\inc\api\hidpi.h 303 driver
Error 3 error C2146: syntax error : missing ';' before identifier 'NTSTATUS' c:\winddk\7600.16385.1\inc\api\hidpi.h 303 driver
Error 4 error C2143: syntax error : missing ';' before '__stdcall' c:\winddk\7600.16385.1\inc\api\hidpi.h 303 driver
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\winddk\7600.16385.1\inc\api\hidpi.h 303 driver
Error 6 error C2377: 'NTSTATUS' : redefinition; typedef cannot be overloaded with any other symbol c:\winddk\7600.16385.1\inc\api\hidpi.h 303 driver
OK so I read somewhere that I have to upgrade the Windows SDK too, I had the Microsoft Windows SDK v6.0A, I downloaded and installed the windows SDK v7.0. But then looks like I have two SDK now? How I properly do the SDK upgrade in visual studio?
I very much appreciate your help,
Thanks,
Carlos

I found a solution, don't know why this is working, but it is!:
In Visual Studio go to:
Tools->Options->Projects->VC++ Directories and then Show directories for: include files.
Add this folders:
C:\WinDDK\7600.16385.1\inc\ddk and C:\WinDDK\7600.16385.1\inc\api
Now here is the trick that solved the problem for me and I don't know why, because seems odd but here it is:
C:\WinDDK\7600.16385.1\inc\ddk -> This directory have to be the first directory in the list!
C:\WinDDK\7600.16385.1\inc\api -> This directory have to be ABOVE "$(WindowsSdkDir)\include" BUT BELOW "$(VCInstallDir)include"
Example:
C:\WinDDK\7600.16385.1\inc\ddk
$(VCInstallDir)include
$(VCInstallDir)atlmfc\include
C:\WinDDK\7600.16385.1\inc\api
$(WindowsSdkDir)\include
$(FrameworkSDKDir)include
Carlos

Related

Latest Visual Studio 2019 v 16.10.0 and _DEPRECATE_TR1_NAMESPACE

I am programming with /std:c++latest in VS2019 v16.10.0. Everything compiled fine with previous version of VS2019. Now I get many errors in header related to _DEPRECATE_TR1_NAMESPACE.
How can I compile around this deprecation?
An example of an error follows:
error C2146: syntax error: missing ';' before identifier 'subtract_with_carry_01'
where the code referenced is:
template <class _Ty, size_t _Wx, size_t _Sx, size_t _Rx>
class _DEPRECATE_TR1_NAMESPACE subtract_with_carry_01
: public _Swc_base<_Ty, _Sx, _Rx, _Swc_01_traits<_Ty, _Wx, _Rx>> { // subtract_with_carry_01 generator
The workaround I found was to
#define _HAS_TR1_NAMESPACE 0
before all header files.
Or to add _HAS_TR1_NAMESPACE=0; in the preprocessor definitions...
This allows me to use latest C++ language!!

Building node contextify using Visual Studio 2013

I'm attempting to get "contextify" to build on my machine. It is a Windows 10 machine.
I am using Windows 10
I have Visual Studio 2013 Professional installed.
I have python 2.7.10, and it's in my PATH.
I have node 4.1.2 32 bit installed (I had previously tried with 64 bit, which is the default that the node website wanted me to download, but it appears to make no difference).
I've got no idea what the right sequence of steps should be, I don't know anything about node-gyp, npm etc, I'm just trying to build a project that has a dependency on contextify.
I've done a clone of the contextify repo from git hub and naively run
`npm install'. I'm using a Visual Studio command prompt (either VS2013 x64 Native Tools Command Prompt or VS2013 x86 Native Tools Command Prompt, makes no difference).
What I get is this:
d:\work\contextify>npm install
> contextify#0.1.14 install d:\work\contextify
> node-gyp rebuild
d:\work\contextify>if not defined npm_config_node_gyp (node "C:\Users\tomq\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
contextify.cc
d:\work\contextify\node_modules\nan\nan.h(263): error C2995: 'v8::Local<T> _NanEnsureLocal(v8::Local<T>)' : function te
mplate has already been defined [d:\work\contextify\build\contextify.vcxproj]
d:\work\contextify\node_modules\nan\nan.h(256) : see declaration of '_NanEnsureLocal'
d:\work\contextify\node_modules\nan\nan.h(661): error C3083: 'smalloc': the symbol to the left of a '::' must be a type
[d:\work\contextify\build\contextify.vcxproj]
d:\work\contextify\node_modules\nan\nan.h(661): error C2039: 'FreeCallback' : is not a member of 'node' [d:\work\contex
tify\build\contextify.vcxproj]
d:\work\contextify\node_modules\nan\nan.h(661): error C2061: syntax error : identifier 'FreeCallback' [d:\work\contexti
fy\build\contextify.vcxproj]
d:\work\contextify\node_modules\nan\nan.h(665): error C2065: 'callback' : undeclared identifier [d:\work\contextify\bui
ld\contextify.vcxproj]
d:\work\contextify\node_modules\nan\nan.h(665): error C2065: 'hint' : undeclared identifier [d:\work\contextify\build\c
ontextify.vcxproj]
d:\work\contextify\node_modules\nan\nan.h(672): error C2665: 'node::Buffer::New' : none of the 4 overloads could conver
t all the argument types [d:\work\contextify\build\contextify.vcxproj]
C:\Users\tomq\.node-gyp\4.1.2\include\node\node_buffer.h(43): could be 'v8::MaybeLocal<v8::Object> node::Buff
er::New(v8::Isolate *,char *,size_t)'
C:\Users\tomq\.node-gyp\4.1.2\include\node\node_buffer.h(31): or 'v8::MaybeLocal<v8::Object> node::Buff
er::New(v8::Isolate *,v8::Local<v8::String>,node::encoding)'
while trying to match the argument list '(v8::Isolate *, const char *, uint32_t)'
d:\work\contextify\node_modules\nan\nan.h(676): error C2664: 'v8::Local<v8::Object>::Local(const v8::Local<v8::Object>
&)' : cannot convert argument 1 from 'v8::MaybeLocal<v8::Object>' to 'const v8::Local<v8::Object> &' [d:\work\contextif
y\build\contextify.vcxproj]
Reason: cannot convert from 'v8::MaybeLocal<v8::Object>' to 'const v8::Local<v8::Object>'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be cal
led
d:\work\contextify\node_modules\nan\nan.h(683): error C2039: 'Use' : is not a member of 'node::Buffer' [d:\work\context
ify\build\contextify.vcxproj]
d:\work\contextify\node_modules\nan\nan.h(683): error C3861: 'Use': identifier not found [d:\work\contextify\build\cont
extify.vcxproj]
I have read the Contextify Windows Install Guide, but it doesn't really help me. I have read many other posts as well.
Am I supposed to be able to get this to compile using Visual Studio 2013?
Thanks.
I've got same issue.
I've solved this problem.
Contextify is not supported in node 4.x.
So I've downgrade node to 0.10.x, then works fine.
Alyosha.

C++/CLI include problems

doing some C++/CLI coding again, and running into issues. Working in VS2008 if it matters at all.
Here's a mock up of what I am trying to do. In reality ClassA is the GUI and ClassB is the backend that the gui needs to interact with. I am trying to give them access to eachother by passing them to eachother, but I cannot properly get them in scope to create a reference to the other one.
http://pastie.org/private/tnyxazwtyzv3luddz7seq
If you have any input I would greatly appreciate it. I have spent much of today looking online and this solution I currently have has gotten me quite close but I am still getting compile errors. Here's what I am now getting:
Error 1 error C2653: 'NameSpaceB' : is not a class or namespace name c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\A.h 12 myhello
Error 2 error C2143: syntax error : missing ';' before '^' c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\A.h 12 myhello
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\A.h 12 myhello
Error 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\A.h 12 myhello
Error 5 error C2653: 'NameSpaceA' : is not a class or namespace name c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\B.h 12 myhello
Error 6 error C2143: syntax error : missing ';' before '^' c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\B.h 12 myhello
Error 7 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\B.h 12 myhello
Error 8 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\B.h 12 myhello
This is the same error I am getting in my actual project, so I know it's something funky with my configuration.
/*B.h File Contents*/
#ifndef CLASSB_H
#define CLASSB_H
#include "A.h"
Remove the #include "A.h" part and you're golden. Since class B doesn't use A (at least in the definition), there's no need for the include.

Issue in convert project from vc6 to vc9

I have a project that was build in vc6,Now I have to convert it into vc9.
In the code there is line
CMapStringToOb cLogPathMap;
ofstream tlogFile;
But when I build the project the following error occur.
error C2146: syntax error : missing ';' before identifier 'tlogFile'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
When I go to definition of ofstream the file iosfwd is opened where ofstream defined as
typedef basic_ofstream<char, char_traits<char> > ofstream;
The following microsoft suggests to include fstream:
http://msdn.microsoft.com/en-us/library/e9cabcax%28v=vs.90%29.aspx
So put the following line in your header includes for that c++ file:
#include <fstream>

Problems during Migration from VS 2003 to VS 2008

I have converted one of my Visual studio 2003 projects into VS2008 and when trying to build the project in VS2008 I get the below mentioned error.
In oledb.h, I have
typedef LONG DBROWCOUNT;
and in sybdb.h, I have
#define DBROWCOUNT 16
When I compile, I get the following errors:
c:\program files\microsoft sdks\windows\v6.0a\include\oledb.h(633) : error C2143: syntax error : missing ';' before 'constant'
c:\program files\microsoft sdks\windows\v6.0a\include\oledb.h(633) : error C2059: syntax error : 'constant'
c:\program files\microsoft sdks\windows\v6.0a\include\oledb.h(3005) : error C2059: syntax error : 'constant'
If I comment the //#define DBROWCOUNT 16, then these errors are solved,but I am not supposed to make changes in code, so please help me to come over this error,thanks in advance.
The problem seems to be that DBROWCOUNT is defined as 16 so it is replaced by preprocessor which results in the line
typedef LONG DBROWCOUNT;
being converted to
typedef LONG 16;
after preprocessing, which is clearly an error. But without looking at the code I can't say why this wasn't happening in vs2003.
While I can't speak to how this was not a problem with VC 2003, the main issues here is that you've defined DBROWCOUNT as both a type and a macro constant (which isn't allowed, as you know.) You're going to have to make a change somewhere, or else you won't be able to fix the compiler error. If oledb.h is a system header, then the change will have to be to your constant:
#define DBROWCOUNT 16
Can you change that define macro to read something like:
#define dbRowCount_k 16
And then replace DBROWCOUNT with dbRowCount_k in the places in your code where you are using that value as an integer (as opposed to a type)?

Resources