M. Yal
M. Yal

Reputation: 53

Missing type specifier

While compiling below code I am getting missing type specifier error. Any way I can solve this issue? I have been trying for few days now and couldnt make any progress. Done almost everything that was suggested for this similar issue but cant seem to get through

CPP

#include "MemoryProtection.h"
#include "Resources.h"
#include "stdafx.h"


pWriteProcessMemory pfnWriteProcessMemory = NULL;
pReadProcessMemory pfnReadProcessMemory = NULL;

HEADER

#pragma once

#include <Windows.h>
#include "3rd\detours.h"
#include <Psapi.h>
#include <atlstr.h>

#pragma comment(lib, "Detours.lib")

typedef LONG NTSTATUS;

#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)


LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam);

typedef BOOL(WINAPI* pReadProcessMemory) (HANDLE hProcess, LPCVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesRead);
typedef BOOL(WINAPI* pWriteProcessMemory) (HANDLE hProcess, LPVOID lpBaseAddress, LPCVOID lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesWritten);

ERROR

Severity    Code    Description Project File    Line    Suppression State
Error   C4430   missing type specifier - int assumed. Note: C++ does not support default-int        6   
Error   C2146   syntax error: missing ';' before identifier 'pfnWriteProcessMemory'     6   
Error   C4430   missing type specifier - int assumed. Note: C++ does not support default-int        7   
Error   C2146   syntax error: missing ';' before identifier 'pfnReadProcessMemory'      7   
Error   C4430   missing type specifier - int assumed. Note: C++ does not support default-int        8   

Upvotes: 0

Views: 2323

Answers (1)

Mihayl
Mihayl

Reputation: 3911

If you're using pre-compiled headers #include "stdafx.h" should be the first pre-processor line. Otherwise all previous includes are overwritten.

/Yu (Use Precompiled Header File)

The compiler treats all code occurring before the .h file as precompiled. It skips to just beyond the #include directive associated with the .h file, uses the code contained in the .pch file, and then compiles all code after filename. -- https://msdn.microsoft.com/en-us/library/z0atkd6c.aspx

See also What's the use for “stdafx.h” in Visual Studio? and StdAfx.h for Novices on cplusplus.com.

Upvotes: 1

Related Questions