Can't include DirectShow sample and compile it (PushSourceDesktop) - c++

So I'm trying to compile the PushSourceDesktop sample with my other project so I can use the 'new' keyword to make an object directly without loading an external dll. I've included all the files in my project and added my precompiled header to the .cpp files. I'm down to these errors that I can't really figure out even with the help of google and various other searches. Hoping someone here might be able to shed some light, thanks in advance!
Error 4 error C2065: 'm_pString' : undeclared identifier c:\program files\microsoft sdks\windows\v7.1\samples\multimedia\directshow\baseclasses\wxdebug.h 292 1 record3
Error 5 error C2065: 'm_pString' : undeclared identifier c:\program files\microsoft sdks\windows\v7.1\samples\multimedia\directshow\baseclasses\wxdebug.h 316 1 record3
Error 1 error C2146: syntax error : missing ';' before identifier 'm_pString' c:\program files\microsoft sdks\windows\v7.1\samples\multimedia\directshow\baseclasses\wxdebug.h 295 1 record3
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft sdks\windows\v7.1\samples\multimedia\directshow\baseclasses\wxdebug.h 295 1 record3
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft sdks\windows\v7.1\samples\multimedia\directshow\baseclasses\wxdebug.h 295 1 record3
8 IntelliSense: identifier "PTCHAR" is undefined c:\program files\microsoft sdks\windows\v7.1\samples\multimedia\directshow\baseclasses\wxdebug.h 295 5

The problem is related to order of inclusion of SDK headers. You perhaps need to add #include <tchar.h> somewhere on top of the code since PTCHAR is that compiler is unable to find.
Because DirectShow Base Classes is quite specific class base, I would suggest that you don't mix it with other C++ code you are having (such as ATL, WTL or MFC). This is possible , but this is likely to keep causing issues similar to the one in your question.
Instead, you can keep your filter in separate DLL, you can instantiate it via CoCreateInstance or privately through DllGetClassObject/CreateInstance, and communicate to it over private interface.

Related

Using Boost.Json lib in Visual Studio 2013

I have been trying to use new Boost.Json lib that was launched in the latest version of boost 1.75.0. For testing purposes I created an empty VS project and added one file and tried to build it. I added the directory in the project's additional include directory. This is what my source file looks like:
#include <boost\json.hpp>
void main(){
return;
}
When I compile this I get following error:
Error 8 error C1903: unable to recover from previous error(s); stopping compilation
C:\Libraries\boost_1_75_0\boost\json\detail\config.hpp 311 1 Project1
Error 5 error C2065: 'T' : undeclared identifier
C:\Libraries\boost_1_75_0\boost\json\detail\config.hpp 311 1 Project1
Error 7 error C2143: syntax error : missing ';' before
'boost::json::detail::static_const<T>::value'
C:\Libraries\boost_1_75_0\boost\json\detail\config.hpp 311 1 Project1
Error 2 error C2146: syntax error : missing ';' before identifier 'T'
C:\Libraries\boost_1_75_0\boost\json\detail\config.hpp 308 1 Project1
Error 4 error C2146: syntax error : missing ';' before identifier 'T'
C:\Libraries\boost_1_75_0\boost\json\detail\config.hpp 311 1 Project1
Error 6 error C2923: 'boost::json::detail::static_const' : 'T' is not a valid template type
argument for parameter 'T' C:\Libraries\boost_1_75_0\boost\json\detail\config.hpp 311 1 Project1
Error 1 error C3646: 'noexcept' : unknown override specifier
C:\Libraries\boost_1_75_0\boost\json\detail\config.hpp 292 1 Project1
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Libraries\boost_1_75_0\boost\json\detail\config.hpp 308 1 Project1
Just to verify if I included the boost lib right, I wrote another code
#include <boost\property_tree\json_parser.hpp>
void main(){
return;
}
and it compiled fine. The reason I want to use json lib instead of property trees is because I want to retain the data type of the json objects whereas trees parse everything in string. Any help will be really appreciated. Thank you.
Boost.JSON is not tested to compile with Visual Studio 2013. I doubt that it could ever work, as that version of the IDE and compiler does not support C++11 sufficiently for the library.

"Triangle" with VS2012?

There is a triangular mesh generator (Shewchuk, CMU), "Triangle", that are recommended by people due to its lightweight. It is written in C. However I cannot use it in my VS2012 C++ project. I am compiling it using x64 platform. I am on Windows 7 64-bit.
Basically, I compile the triangle.c as the makefile described. So, a triangle.o is generated. I then
added triangle.o as additional dependencies in my solution,
added triangle.c and triangle.h in my project .
changed triangle.c in C/C++ precompiled header option, to "not using precompiled header"
Then I got tons of errors like this:
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(430): error C2143: syntax error : missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(430): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(497): error C2143: syntax error : missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(497): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(498): error C2143: syntax error : missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(498): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(2517): warning C4391: 'SHORT _InterlockedIncrement16(volatile SHORT *)' : incorrect return type for intrinsic function, expected 'short'
I am just wondering, is there anyway to make the triangular mesh generator work with VS2012 C++ project? If so, what is the right way to set it up on VS2012 C++ x64?
You might want to have a look at this: Compilation errors of a simple C++ project in VS 2012.RC 4
disable pre-compiled headers, and delete the pch file from the intermediate directory.
This initially didn't work for me, so I tried moving #include at the top of the file, before all other includes, and this worked for me.

VS2012 mixing C and Cpp, library clash

I am trying to combine some C and C++ code in a project, and before I had no issues with this, but I'm now trying out VS2012 for the first time and I get a lot of errors from a TR1 header that I didn't include explicitely.
I'm thinking it might be a mixup because it's trying to compile my c code with this cpp header. It looks like a C compiler error trying to understand C++ template code. Where can I figure this out from the VS2012 interface? Do I need to do something to my c and cpp files to make the compiler treat them properly?
Error 1 error C2143: syntax error : missing '{' before '<' C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xtr1common 15 1 example~
Error 2 error C2059: syntax error : '<' C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xtr1common 15 1 example~
Error 3 error C2143: syntax error : missing '{' before '<' C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xtr1common 20 1 example~
Error 4 error C2059: syntax error : '<' C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xtr1common 20 1 example~
Error 5 error C2016: C requires that a struct or union has at least one member C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xtr1common 28 1 example~
Never mind. It has been a while since I've used VS and forgot that it doesn't necessarily treat cpp files as c++. I had to set the "compile as" option to c++.

Moving C++ project, errors in atlplus.h

I am trying to move an old C++ project to VS2010.
The last version of VS to compile it was VS2005, as far as I know. I already fixed a bunch of errors but now I am stuck,
since I am getting errors in atlplus.h, which is a VC10 header file.
Error 1 error C2065: 'CStringW' : undeclared identifier C:\Program
Files (x86)\Microsoft Visual Studio
10.0\VC\atlmfc\include\atlplus.h 692 1
Error 2 error C2146: syntax error : missing ';' before
identifier 'strW' C:\Program Files
(x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlplus.h 692 1
Error 3 error C3861: 'strW': identifier not found
C:\Program Files
(x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlplus.h 692 1
Error 4 error C2065: 'strW' : undeclared identifier C:\Program Files
(x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlplus.h 693 1
Does anyone have any idea? I've been stuck here since last week.
You need to include atlstr.h before any headers that use CString.
CString has been moved to the atlstr.h header file.
I met the similar problem. please try to include atlbase.h instead of atlstr.h.
You can see a comment line in file atlplus.h:
//Avoid using <atlstr.h> except in the registry templates (for circular dependencies).

syntax error : missing ';' before identifier 'PVOID64' when compiling winnt.h

I've recently got the source-code on a application. When im trying to build the solution, I get an error in all parts where winnt.h is included. The error codes differs a bit, but they always point to these lines in winnt.h:
typedef void *PVOID;
typedef void * POINTER_64 PVOID64;
and
struct {
DWORD crc;
BYTE rgbReserved[14];
} CRC;
So, what could be the cause of this? winnt.h is a standard header and has not been modified. Does it has something to do with me using VS 2010, or me using 64-bit windows? or is it some sort of configuration which is needed?
EDIT:
Here's the exact error-codes:
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(290): error C2146: syntax error : missing ';' before identifier 'PVOID64'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(290): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(8992): error C2146: syntax error : missing ';' before identifier 'Buffer'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(8992): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(8992): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(11525): error C2059: syntax error : 'constant'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(11525): error C2238: unexpected token(s) preceding ';'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(11556): error C2059: syntax error : 'constant'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(11556): error C2238: unexpected token(s) preceding ';'
You need to include windows.h rather than winnt.h. When you include windows.h it will, in turn, include winnt.h. You need to do it this way for the necessary macros to be in place that are needed to compile winnt.h.
In this case, POINTER_64 is defined in BaseTsd.h like this:
#define POINTER_64 __ptr64
But if you include winnt.h before including windows.h then POINTER_64 is not defined.
If you are using DirectX SDK, try changing the VC++ Directories for include and lib to be searched last.
It looks like your configuration of the Windows SDK is invalid.
This error is caused by the fact that the compiler is unable to recognize the 'POINTER_64' statement.
You may workaround this problem by replacing 'POINTER_64' with '__ptr64'.
I had the same issue recently. Then I've reinstalled the latest version of the Windows SDK and this fixed the problem.
UPDATE
#David Heffernan, correctly points to the fact that one should include windows.h instead of winnt.h
Try to remove DirectX SDK if you have one.
Here bug is accepted:
http://connect.microsoft.com/VisualStudio/feedback/details/508204/vc10-0-errors-while-compiling-winnt-h
Corrected manually syntax in winnt.h :
typedef void * POINTER_64 PVOID64; => typedef void * POINTER_64, * PVOID64;
If you are using librdkafka, you will get this error whenever "Windows.h" included.
I fixed it by rename "librdkafka/include/basetsd.h" to a different name, or access
this library header via sub path!
I think the author of this library made this file to deal with OS platform compatibility. But with the same file name "basetsd.h" as Windows Core, it just confusing Visual Studio.