MFC - D3DCOLORVALUE undefined in base MFC application - c++

I'm using Visual Studio 2013 to create a new MFC Application.
I created the application using the setup wizard, left it on all the default values.
When testing if it even runs before adding anything it gave the compile error:
IntelliSense: identifier "D3DCOLORVALUE" is undefined
followed by a lot of:
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Why would this be happening in a stock standard application straight out of the wizard? And how would I get this working?

d2dbasetypes.h was giving the error when trying to define D2D_COLOR_F.
I googled the base type (D3DCOLORVALUE) and found that it's supposed to be in "D3D9Types.h"
I added #include "D3D9Types.h" to the top of the d2dbasetypes header file and it seems to have fixed the problem.
I don't know why this isn't included in the generated code by default...

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

Visual Studio C++ NPAPI plugin with Twain support

I want to make a Google Chrome plugin that use Twain to remote control a Digital Camera.
I want this to run on Windows and I'm using Visual Studio Express 2012 C++.
I have this sample for NPAPI and this sample of CppWrapper for Twain which has 3 interesting files (TwainCpp.cpp TwainCpp.h twain.h)
Before doing anything, I want to merge these two projects.
First step: putting twain.h in the npsimple project which failed, twain.h errors caught.
Second step: putting CppTwain in npsimple, which also failed because twain.h "contains" errors.
Problem is that when I create an empty project, and put twain.h in it, there is no error! So I tried to put npsimple files in that empty project, and this time I get error from npsimple files..
Error type :
I have this code in twain.h :
#ifdef _MSWIN_
typedef HANDLE TW_HANDLE;
typedef LPVOID TW_MEMREF;
and I get plenty of errors like :
error C2146: syntax error : missing ';' before identifier 'TW_HANDLE'
How can I merge these projects?
HANDLE is an unspecified type because you don't include anything that is specificing it. You'll want to include windows.h.
Obviously there is no error when you add only the twain.h header file to the empty project - you haven't added any sources to compile, hence there can be no compilation errors.

error C2146 trying to compile a basic HLSL shader in C++

i've just started to learn the basics of HLSL using C++, im following the tutorials on a book, the first basic shader is:
float4 VS_Main( float4 pos:POSITION):SV_POSITION
{
return pos;
}
but i get a lot of errors at compile time:
error C2146: syntax error: ';' missing before the identifier 'VS_Main'
error C4430: missing type specifier, int assumed. Note: default-int is no longer supported
error C2146: syntax error : ')' missing before the identifier 'pos'
error C2059: syntax errorlooks like a function definition, but there is no formal parameter list.
error C2059: syntax error: '{'
it really looks like the compiler cant handle HLSL at all...maybe VS2012 express doesnt support HLSL?
thanks in advance
HLSL is not C++. You should compile shaders with shader compiler, and C++ with C++ compiler — do not mix. There are two options for compiling HLSL.
Use command-line utility fxc.exe that is included in DirectX SDK (docs and usage here at MSDN). It generates a file that you should load in runtime by some of the ways described here.
Compile your shader at runtime by using D3DCompileFromFile function.
There are pros and cons about each of the variants. In short, pre-compiling at build time gives you some time gain at runtime, while compiling at runtime is more flexible and comfortable at development stage (no need to remember to recompile it or to use post-build scripts) but is more error-prone. Choose by yourself.
The code looks fine for HLSL. If you want to compile it from within VS2012 set the ".fx" file to build using the HLSL shader compiler. Right click the file select properties. Then select General and Item Type should be set to HLSL compiler.
If you really want to make shaders using C++ you could look into C++AMP to see if it may suit your needs.
it really looks like the compiler cant handle HLSL at all...maybe VS2012 express doesnt support HLSL?
No C++ compiler does. It is not supposed to be handled by the compiler.
You need to turn it into a resource and copy it into the bin directory using post-build scripts, and load the HLSL at runtime.
See also: http://www.directxtutorial.com/Lesson.aspx?lessonid=11-4-5

LIBTIFF not able to work with C++ project

Libtiff is a C library, but I want to use it with a C++ project in Qt Creator. Does anyone know how to do this? I get compile time errors when I try to use the C library, so I'm not sure what to do.
The compile time error I get is:
c:\libtiff\libtiff\tiff.h:69: error: C4430: missing type specifier - int assumed. Note: C++ does not support default-int
for the line:
typedef TIFF_INT8_T int8;
plus a bunch of more similar errors. Someone please help.
You need to wrap the include statements on an extern C block --
extern "C"{
#include "tiff.h"
}
This tells the compiler to view those files as C, not C++, so you should not get strict C++ errors.

error PRJ0019: A tool returned an error code from "moc'ing qt/gui/QFloatSlider.h

I'm building a big C++ project on Visual Studio 2008 I'm getting this error message and I don't understand it. Is it a failure to include the .h file?
I know this thread is dated, but I had the exact same problem with a C++ project on Visual Studio 2008, here was my resolution...
One of the things the VS2008 compile told me was that it generated a log on:
"file://C:\Documents and Settings\adam\My Documents\Visual Studio 2008\Projects\MyProject\Debug\BuildLog.htm"
This log demystified the problem for me.
In my case, it had the following explicit error message:
c:\Documents and Settings\adam\My Documents\Visual Studio 2008\Projects\MyProject\MyProject\UnitTests.h(36): Error: Meta object features not supported for nested classes
The problem had been that INSIDE the class I defined here, I defined yet another internal (nested) class, that included the QT macro (so I could define signals and slots):
Q_OBJECT
Obviously QT wasn't happy that this class was nested/internal in another class. So I simply moved the class definition outside (IE made it non-internal).
No, it is not.
Did you look up the error code error PRJ0019.