While compiling a C code, I'm getting the following error:
c:\users\kbarman\documents\mser\vlfeat-0.9.13-try\mser\stringop.c(71): error C2491: 'vl_string_parse_protocol' : definition of dllimport function not allowed
In the file stringop.c, I have the following function:
VL_EXPORT char *
vl_string_parse_protocol (char const *string, int *protocol)
{
char const * cpt ;
int dummy ;
/* handle the case prot = 0 */
if (protocol == 0)
protocol = &dummy ;
/* look for :// */
cpt = strstr(string, "://") ;
if (cpt == 0) {
*protocol = VL_PROT_NONE ;
cpt = string ;
}
else {
if (strncmp(string, "ascii", cpt - string) == 0) {
*protocol = VL_PROT_ASCII ;
}
else if (strncmp(string, "bin", cpt - string) == 0) {
*protocol = VL_PROT_BINARY ;
}
else {
*protocol = VL_PROT_UNKNOWN ;
}
cpt += 3 ;
}
return (char*) cpt ;
}
And VL_EXPORT is defined as follows:
# define VL_EXPORT extern "C" __declspec(dllimport)
Can somebody please tell me what is causing this error and how I can get rid of it?
As documentation states, dllimport function are not allowed to have a body right there.
[...] functions can be declared as dllimports but not defined as
dllimports.
// function definition
void __declspec(dllimport) funcB() {} // C2491
// function declaration
void __declspec(dllimport) funcB(); // OK
You are saying that the function is external, defined in a Dll. And then you are defining it in your code. This is illegal since is has to be one or the other, but not both external and internal.
My guess is that you simply need to change dllimport to dllexport. I assume that you are building this code into a library.
Related
I just tested a toy Excel add-in project, cross building the XLL with mingw32 tool chains.
Here is my code:
//testXLL.c
#include "windows.h"
#include "xlcall.h"
#define MEMORYSIZE 65535000
char vMemBlock[MEMORYSIZE];
int vOffsetMemBlock =0;
LPSTR GetTempMemory(int cBytes){
LPSTR lpMemory;
if(vOffsetMemBlock + cBytes > MEMORYSIZE)
return 0;
else{
lpMemory = (LPSTR) &vMemBlock + vOffsetMemBlock;
vOffsetMemBlock += cBytes;
if(vOffsetMemBlock & 1) vOffsetMemBlock++;
return lpMemory;
}
}
LPXLOPER TempStr(LPSTR lpstr){
LPXLOPER lpx;
int chars;
lpx = (LPXLOPER)GetTempMemory(sizeof(XLOPER));
if(!lpx) return 0;
chars = lstrlen(lpstr);
if(chars>255) chars=255;
lpx->val.str=(char*)GetTempMemory((sizeof(char)*chars+1));
if(!lpx->val.str) return 0;
strncpy(lpx->val.str, lpstr,chars);
lpx->val.str[0]=(BYTE) chars;
//lpx->val.str[chars]='\0';
lpx->xltype = xltypeStr;
return lpx;
}
#ifdef __cplusplus
extern "C" {
#endif
__declspec(dllexport) double __stdcall myadd2(double a1,double a2){
return a1+a2;
}
static char functionTable[11][255] =
{" myadd2", // procedure
" BBB", // type_text
" add", // function_text
" add1,add2", // argument_text
" 1", // macro_type
" category", // category
" ", // shortcut_text
" some help topic", // help_topic
" Adds toy", // function_help
" 1st.", // argument_help1
" 2nd" // argument_help2
};
__declspec(dllexport) int __stdcall xlAutoOpen(){
LPXLOPER pxDLL;
Excel4(xlGetName,pxDLL,0);
XLOPER xlRegArgs[11];
for(int i = 0; i < 11; i++){
xlRegArgs[i] = *TempStr(functionTable[i]);
}
Excel4(xlfRegister, 0, 12,
pxDLL,
&xlRegArgs[0], &xlRegArgs[1], &xlRegArgs[2],
&xlRegArgs[3], &xlRegArgs[4], &xlRegArgs[5],
&xlRegArgs[6], &xlRegArgs[7], &xlRegArgs[8],
&xlRegArgs[9], &xlRegArgs[10]);
return 1;
}
__declspec(dllexport) LPXLOPER __stdcall xlAddInManagerInfo(LPXLOPER xlAction) {
static XLOPER xlReturn, xlLongName, xlTemp;
xlTemp.xltype = xltypeInt;
xlTemp.val.w = xltypeInt;
Excel4(xlCoerce, &xlReturn, 2, xlAction, &xlTemp);
if(1 == xlReturn.val.w) {
xlLongName = *TempStr(" xll-name");
} else {
xlLongName.xltype = xltypeErr;
xlLongName.val.err = xlerrValue;
}
return &xlLongName;
}
#ifdef __cplusplus
}
#endif
I built this testXLL.c file in Ubuntu:
>i686-w64-mingw32-gcc -shared -Wl,--kill-at testXLL.c -o win.xll -L. -lxlcall32
This generates the "win.xll" successfully but, when loading this win.xll, Excel crashes.
In Windows 10, I tried to use gdb to debug it, but I can't catch break point in the xll file – it got disabled automatically when loading. But I can see in the gdb output, it is a segmentation fault when Excel crashes.
XLOPER xlRegArgs[11];
for(int i = 0; i < 11; i++){
xlRegArgs[i] = *TempStr(functionTable[i]);
}
What's weird is that, if I substitute the above for loop with the following line-by-line assignments in the xlAutoOpen function, the compiled XLL file works fine in Excel:
XLOPER xlRegArgs[11];
xlRegArgs[0] = *TempStr(functionTable[0]);
xlRegArgs[1] = *TempStr(functionTable[1]);
xlRegArgs[2] = *TempStr(functionTable[2]);
xlRegArgs[3] = *TempStr(functionTable[3]);
xlRegArgs[4] = *TempStr(functionTable[4]);
xlRegArgs[5] = *TempStr(functionTable[5]);
xlRegArgs[6] = *TempStr(functionTable[6]);
xlRegArgs[7] = *TempStr(functionTable[7]);
xlRegArgs[8] = *TempStr(functionTable[8]);
xlRegArgs[9] = *TempStr(functionTable[9]);
xlRegArgs[10] = *TempStr(functionTable[10]);
Please enlighten me. What's the difference between these two assignment approaches?
Although I don't (yet) have a full explanation for this behaviour, I'm posting this as a possible 'workaround', which I have used in a very similar case I encountered in one of my projects.
The issue appears to be some form of 'stack corruption' caused by the use of the function-local variable (i) used as the loop index; converting this to a global/static variable will likely fix the issue. The following code snippet is a suggested fix (I have changed the name of the index variable to avoid possible name clashes elsewhere in the code):
///...
static int regloop; // Used as the loop index, below...
__declspec(dllexport) int __stdcall xlAutoOpen(){
LPXLOPER pxDLL;
Excel4(xlGetName,pxDLL,0);
XLOPER xlRegArgs[11];
for(regloop = 0; regloop < 11; regloop++){
xlRegArgs[regloop] = *TempStr(functionTable[regloop]);
}
Here's the section of code from my aforementioned project (but note this is C++/MFC) that exhibits the same sort of behaviour – but only in x86 builds (x64 builds work without issue):
static int plin; // NOTA BENE:- We use this in the two functions below, as the use of
// a local 'plin' loop index is prone to induce stack corruption (?),
// especially in MSVC 2017 (MFC 14) builds for x86.
void BasicApp::OnUpdatePICmd(uint32_t nID, void *pUI)
{
//! for (int plin = 0; plin < Plugin_Number; ++plin) { // Can cause problems - vide supra
for (plin = 0; plin < Plugin_Number; ++plin) {
BOOL mEbl = FALSE; int mChk = -1;
if ((Plugin_UDCfnc[plin] != nullptr) && Plugin_UDCfnc[plin](nID, &mEbl, &mChk)) {
CommandEnable(pUI, mEbl ? true : false);
if (mChk >= 0) CmdUISetCheck(pUI, mChk);
return;
}
}
CommandEnable(pUI, false);
return;
}
(The Plugin_UDCfnc is a static array member of the BasicApp class.)
I have, in the years since the above code was written, had occasional 'fleeting insights' into why this is happening but, as of now, I can't offer a more robust fix. I shall revisit the issue and update this post if I should stumble upon a resolution. In the meantime, others are welcome to take this as a 'clue' and post their own explanations/solutions.
I'm studying THIS tutorial for tinyos and I wanted to try it out. I try to create the packet but it gives me the following error. I don't know what's wrong. It is probably something simple but I can't figure out what it is.
#include "TestMsg.h"
...
event void AMControl.startDone(error_t error) {
if (error == SUCCESS) {
call Leds.led0On();
//create packet
TestMsg_t* msg = call Packet.getPayload(&packet, sizeof(TestMsg_t));
msg->NodeID = TOS_NODE_ID;
//
// //TODO in the meantime this can change
// button_state_t val = call Get.get();
// msg->Data = ( val == BUTTON_PRESSED ? 1 : 0 );
//
// //send packet
// if (call AMSend.send(AM_BROADCAST_ADDR, &packet, sizeof(TestMsg_t)) == SUCCESS) {
// radioBusy = TRUE;
// }
} else {
call AMControl.start();
}
}
...
Here is TestMsg.h
#ifndef TEST_MSG_H
#define TEST_MSG_H
typedef nx_struct _TestMsg {
nx_uint16_t NodeID;
nx_uint8_t Data;
} TestMsg_t;
enum {
AM_RADIO = 6
};
#endif /* TEST_MSG_H */
Here is the part where it is declared in the video
The error I get it this:
In file included from /home/advanticsys/ws/TestRadio/src/TestRadioAppC.nc:5:
In component `TestRadioC':
/home/advanticsys/ws/TestRadio/src/TestRadioC.nc: In function `AMControl.startDone':
/home/advanticsys/ws/TestRadio/src/TestRadioC.nc:43: syntax error before `*'
/home/advanticsys/ws/TestRadio/src/TestRadioC.nc:44: `msg' undeclared (first use in this function)
/home/advanticsys/ws/TestRadio/src/TestRadioC.nc:44: (Each undeclared identifier is reported only once
/home/advanticsys/ws/TestRadio/src/TestRadioC.nc:44: for each function it appears in.)
Update
Something is wrong with structs and headers.
#include "Szar.h"
#include "BarType.h"
module SzarP {
uses interface Boot;
uses interface Leds;
}
implementation {
event void Boot.booted() {
// TODO Auto-generated method stub
call Leds.led0On();
Szar_t foo;
Szar_t *szar = &foo;
BarType_t barVar;
barVar.data = 0;
BarType_t *pBarVar = &barVar;
pBarVar->data = 1;
}
}
Here are the 2 header files.
#ifndef SZAR_H
#define SZAR_H
typedef nx_struct _Szar {
nx_uint8_t szar1;
nx_uint16_t szar2;
} Szar_t;
#endif /* SZAR_H */
#ifndef BAR_TYPE_H
#define BAR_TYPE_H
typedef struct _BarType {
uint8_t id;
uint32_t data;
} BarType_t;
#endif /* BAR_TYPE_H */
And the errors:
In file included from /home/advanticsys/ws/Szar/src/SzarAppC.nc:6:
In component `SzarP':
/home/advanticsys/ws/Szar/src/SzarP.nc: In function `Boot.booted':
/home/advanticsys/ws/Szar/src/SzarP.nc:15: syntax error before `foo'
/home/advanticsys/ws/Szar/src/SzarP.nc:19: `barVar' undeclared (first use in this function)
/home/advanticsys/ws/Szar/src/SzarP.nc:19: (Each undeclared identifier is reported only once
/home/advanticsys/ws/Szar/src/SzarP.nc:19: for each function it appears in.)
/home/advanticsys/ws/Szar/src/SzarP.nc:20: syntax error before `*'
/home/advanticsys/ws/Szar/src/SzarP.nc:21: `pBarVar' undeclared (first use in this function)
For some strange reason I have to declare EVERY variable outside the function, and then it works. Example:
bool radioBusy = FALSE;
message_t packet;
TestMsg_t *messageToSend;
button_state_t buttonState;
event void AMControl.startDone(error_t error) {
if (error == SUCCESS) {
call Leds.led0On();
messageToSend = call Packet.getPayload(&packet, sizeof(TestMsg_t));
messageToSend->NodeID = TOS_NODE_ID;
//TODO in the meantime this can change
buttonState = call Get.get();
messageToSend->Data = ( buttonState == BUTTON_PRESSED ? 1 : 0 );
//send packet
if (call AMSend.send(AM_BROADCAST_ADDR, &packet, sizeof(TestMsg_t)) == SUCCESS) {
radioBusy = TRUE;
}
} else {
call AMControl.start();
}
}
It also works if I declare my variables at the beginning of the functions/events/commands without any code before them.
I'm sure this has been addressed in the past. My apologies.
I want to understand why I'm getting error LNK2019.
And what direction to take, to get this resolved.
Errors are LNK2019:
unresolved external symbol __imp__ReportError referenced in function _wmain
unresolved external symbol __imp__Options referenced in function _wmain
This occurs when I build solution in Visual Studio 2010 and up.
Contents of header file for the above methods are described like so:
LIBSPEC DWORD Options (int, LPCTSTR *, LPCTSTR, ...);
LIBSPEC DWORD Options (int, LPCTSTR *, LPCTSTR, ...);
Main code:
#include "Everything.h"
BOOL TraverseDirectory(LPTSTR, LPTSTR, DWORD, LPBOOL);
DWORD FileType(LPWIN32_FIND_DATA);
BOOL ProcessItem(LPWIN32_FIND_DATA, DWORD, LPBOOL);
int _tmain(int argc, LPTSTR argv[])
{
BOOL flags[MAX_OPTIONS], ok = TRUE;
TCHAR searchPattern[MAX_PATH + 1], currPath[MAX_PATH_LONG+1], parentPath[MAX_PATH_LONG+1];
LPTSTR pSlash, pSearchPattern;
int i, fileIndex;
DWORD pathLength;
fileIndex = Options(argc, argv, _T("Rl"), &flags[0], &flags[1], NULL);
pathLength = GetCurrentDirectory(MAX_PATH_LONG, currPath);
if (pathLength == 0 || pathLength >= MAX_PATH_LONG) { /* pathLength >= MAX_PATH_LONG (32780) should be impossible */
ReportError(_T("GetCurrentDirectory failed"), 1, TRUE);
}
if (argc < fileIndex + 1)
ok = TraverseDirectory(currPath, _T("*"), MAX_OPTIONS, flags);
else for (i = fileIndex; i < argc; i++) {
if (_tcslen(argv[i]) >= MAX_PATH) {
ReportError(_T("The command line argument is longer than the maximum this program supports"), 2, FALSE);
}
_tcscpy(searchPattern, argv[i]);
_tcscpy(parentPath, argv[i]);
pSlash = _tstrrchr(parentPath, _T('\\'));
if (pSlash != NULL) {
*pSlash = _T('\0');
_tcscat(parentPath, _T("\\"));
SetCurrentDirectory(parentPath);
pSlash = _tstrrchr(searchPattern, _T('\\'));
pSearchPattern = pSlash + 1;
} else {
_tcscpy(parentPath, _T(".\\"));
pSearchPattern = searchPattern;
}
ok = TraverseDirectory(parentPath, pSearchPattern, MAX_OPTIONS, flags) && ok;
SetCurrentDirectory(currPath);
}
return ok ? 0 : 1;
}
static BOOL TraverseDirectory(LPTSTR parentPath, LPTSTR searchPattern, DWORD numFlags, LPBOOL flags)
{
HANDLE searchHandle;
WIN32_FIND_DATA findData;
BOOL recursive = flags[0];
DWORD fType, iPass, lenParentPath;
TCHAR subdirectoryPath[MAX_PATH + 1];
/* Open up the directory search handle and get the
first file name to satisfy the path name.
Make two passes. The first processes the files
and the second processes the directories. */
if ( _tcslen(searchPattern) == 0 ) {
_tcscat(searchPattern, _T("*"));
}
/* Add a backslash, if needed, at the end of the parent path */
if (parentPath[_tcslen(parentPath)-1] != _T('\\') ) { /* Add a \ to the end of the parent path, unless there already is one */
_tcscat (parentPath, _T("\\"));
}
/* Open up the directory search handle and get the
first file name to satisfy the path name. Make two passes.
The first processes the files and the second processes the directories. */
for (iPass = 1; iPass <= 2; iPass++) {
searchHandle = FindFirstFile(searchPattern, &findData);
if (searchHandle == INVALID_HANDLE_VALUE) {
ReportError(_T("Error opening Search Handle."), 0, TRUE);
return FALSE;
}
do {
fType = FileType(&findData);
if (iPass == 1) /* ProcessItem is "print attributes". */
ProcessItem(&findData, MAX_OPTIONS, flags);
lenParentPath = (DWORD)_tcslen(parentPath);
/* Traverse the subdirectory on the second pass. */
if (fType == TYPE_DIR && iPass == 2 && recursive) {
_tprintf(_T("\n%s%s:"), parentPath, findData.cFileName);
SetCurrentDirectory(findData.cFileName);
if (_tcslen(parentPath) + _tcslen(findData.cFileName) >= MAX_PATH_LONG-1) {
ReportError(_T("Path Name is too long"), 10, FALSE);
}
_tcscpy(subdirectoryPath, parentPath);
_tcscat (subdirectoryPath, findData.cFileName); /* The parent path terminates with \ before the _tcscat call */
TraverseDirectory(subdirectoryPath, _T("*"), numFlags, flags);
SetCurrentDirectory(_T("..")); /* Restore the current directory */
}
/* Get the next file or directory name. */
} while (FindNextFile(searchHandle, &findData));
FindClose(searchHandle);
}
return TRUE;
}
static DWORD FileType(LPWIN32_FIND_DATA pFileData)
{
BOOL isDir;
DWORD fType;
fType = TYPE_FILE;
isDir =(pFileData->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
if (isDir)
if (lstrcmp(pFileData->cFileName, _T(".")) == 0
|| lstrcmp(pFileData->cFileName, _T("..")) == 0)
fType = TYPE_DOT;
else fType = TYPE_DIR;
return fType;
}
static BOOL ProcessItem(LPWIN32_FIND_DATA pFileData, DWORD numFlags, LPBOOL flags)
{
const TCHAR fileTypeChar[] = {_T(' '), _T('d')};
DWORD fType = FileType(pFileData);
BOOL longList = flags[1];
SYSTEMTIME lastWrite;
if (fType != TYPE_FILE && fType != TYPE_DIR) return FALSE;
_tprintf(_T("\n"));
if (longList) {
_tprintf(_T("%c"), fileTypeChar[fType - 1]);
_tprintf(_T("%10d"), pFileData->nFileSizeLow);
FileTimeToSystemTime(&(pFileData->ftLastWriteTime), &lastWrite);
_tprintf(_T(" %02d/%02d/%04d %02d:%02d:%02d"),
lastWrite.wMonth, lastWrite.wDay,
lastWrite.wYear, lastWrite.wHour,
lastWrite.wMinute, lastWrite.wSecond);
}
_tprintf(_T(" %s"), pFileData->cFileName);
return TRUE;
}
The error you're getting is from the linker, and it's telling you that it cannot find the definitions of the ReportError and Options functions (both of which are referenced from your main function).
You say that you have included a header file that contains these functions, but that header contains only the declarations of these functions. You know, like their signature. It doesn't have the body (implementation) of the functions. You need the definition for that.
Definitions for functions that you've written are usually located in *.cpp files. If you've written these functions, make sure that the code file that contains their definitions has been added to your project.
For functions that you have not written (i.e. are part of a reusable library of code), you usually provide the linker with a *.lib file that contains what it needs to call the functions. If these functions are from a library, make sure that you've added the *.lib file that came with them to the list of files that the linker will search. To do that in Visual Studio, follow these steps:
Right-click on your project in the Solution Explorer, and open its Properties.
Expand the "Linker" category, and select the "Input" node.
Click in the "Additional Dependencies" field, and press the ... button.
Enter the name of your *.lib file on a new line in the textbox that appears.
Just because you declared a function in a header file, doesn't mean it has a body anywhere.
The link error says the function doesn't have a body.
This is likely because you didn't link to the proper Library (a .lib file).
int getSpeedOfMotorInPercent(int RPM)
{
int speedOfMotor = (RPM/5000.0)*100;
return speedOfMotor;
}
static char *test_GetSpeedOfMotor(int speedInPercent)
{
mu_assert("error, RPM != 70%", speedInPercent == 70);
return 0;
}
static char *run_all_tests(int RPM)
{
mu_run_test(test_GetSpeedOfMotor(RPM));
return 0;
}
I get the error "called object is not a function" on mu_run_test(test_GetSpeedOfMotor(RPM));
I tried removing the pointer of the function but then I get even more errors.
EDIT:
#define mu_assert(message, test) do { if (!(test)) return message; } while (0)
#define mu_run_test(test) do { char *message = test(); tests_run++; if (message) return message; } while (0)
extern int tests_run;
this is the mu_run_test function. It is provided to me like that in the header file.
You're passing test_GetSpeedOfMotor(RPM) as test in the macro, which will result in this code:
char *message = test_GetSpeedOfMotor(RPM)();
Since you're probably using a test framework which you don't want to change, just remove the RPM parameter from the declaration of test_GetSpeedOfMotor function and use it like this:
int testRpmInPercent;
static char *test_GetSpeedOfMotor()
{
mu_assert("error, RPM != 70%", testRpmInPercent == 70);
return 0;
}
static char *run_all_tests(int RPM)
{
testRpmInPercent = RPM;
mu_run_test(test_GetSpeedOfMotor);
return 0;
}
Then you'll have to find an other way of sharing the RPM value with the test function. Like a global variable or with whatever method the test framework has to offer.
If you're willing to change the test framework, I would modify that define to this (remove () after test):
#define mu_run_test(test) do { char *message = test; tests_run++; if (message) return message; } while (0)
I am newbie in C ,with Mingw32 compiler.
Right now i am creating decompiler from IL to C (Native)
The code generated (Without System.Object):
DecompileTestApplication_Program.c
#include "DecompileTestApplication_Program.h"
DecompileTestApplication_Program* DecompileTestApplication_Program__ctor( ) {
if (array__DecompileTestApplication_Program == 0) {
array__DecompileTestApplication_Program=(void**)malloc(sizeof(void*)*(capacity__DecompileTestApplication_Program=4));
}
DecompileTestApplication_Program* this;
//error: 'this' undeclared (first use in this function)
if (count__DecompileTestApplication_Program==0) {
this=(DecompileTestApplication_Program*)malloc(sizeof(DecompileTestApplication_Program));
goto RealConstructor;
}
this=(DecompileTestApplication_Program*)array__DecompileTestApplication_Program[--count__DecompileTestApplication_Program];
RealConstructor:
this->ind = 0;
this->a = 1;
this->b = 3;
//this._inherit_object_( ); //this is OOP tests ,still working on it
return this;
}
void DecompileTestApplication_Program_Main( ) {
int var_0_02;
var_0_02 = 0;
var_0_02 = ( var_0_02 + 1 );
int var_1_08;
var_1_08 = 1;
int var_2_0A;
var_2_0A = 3;
var_1_08 = ( var_1_08 + var_2_0A );
var_0_02 = ( var_0_02 + ( var_1_08 + var_2_0A ) );
DecompileTestApplication_Program_blat = ( DecompileTestApplication_Program_blat + ++DecompileTestApplication_Program_bpa );
}
void DecompileTestApplication_Program__cctor( ) {
DecompileTestApplication_Program_blat = 1;
DecompileTestApplication_Program_bpa = 4;
}
DecompileTestApplication_Program.h
#ifndef DecompileTestApplication_Program
#define DecompileTestApplication_Program
/*
Type's Name: DecompileTestApplication.Program
Time to Parse: 40.0023ms
*/
#include <stdio.h>
typedef struct {
//Variables
int ind;
int a;
int b;
} DecompileTestApplication_Program;
static int DecompileTestApplication_Program_blat;
static int DecompileTestApplication_Program_bpa;
//Methods
void DecompileTestApplication_Program_Main( );
DecompileTestApplication_Program* DecompileTestApplication_Program__ctor( );
void DecompileTestApplication_Program__cctor( );
static int count__DecompileTestApplication_Program=0;
static int capacity__DecompileTestApplication_Program=0;
static DecompileTestApplication_Program** array__DecompileTestApplication_Program=0;
#endif
#main.h
void main();
#main.cpp
//bookmart for includes
#include "DecompileTestApplication_Program.h"
void main() {
//bookmark for initialize
DecompileTestApplication_Program__cctor();
DecompileTestApplication_Program_Main();
}
The error found in the first file.
I searched the resolve for this error for awhile ,
but didn't found any.
#define DecompileTestApplication_Program
That means that everywhere you see the word DecompileTestApplication_Program, it gets removed. As such, your attempted declaration of this:
DecompileTestApplication_Program* this;
expands to
* this;
which attempts to dereference the undeclared variable this. To fix this, change the macro name.