directx 11 LNK error 2005, 2019 and 1120 - c

i'm following a book on how to program with driectx 11 but i still got 3 error even though i've programmed it to be exactly the same and checked for diffrences for almost a full day now. i've got 3 errors
error LNK1120: 1 unresolved externals C:\Users\Me\documents\visual studio 2013\Projects\TestX engine\Debug\TestX engine.exe 1 1 TestX engine
Error 2 error LNK2019: unresolved external symbol _D3DX11CreateEffectFromMemory#20 referenced in function "private: void __thiscall BoxApp::BuildFX(void)" (?BuildFX#BoxApp##AAEXXZ) C:\Users\Me\documents\visual studio 2013\Projects\TestX engine\TestX engine\Box.obj TestX engine
Error 1 error LNK2005: _WinMain#16 already defined in Box.obj C:\Users\Me\documents\visual studio 2013\Projects\TestX engine\TestX engine\InitDirect3D.obj TestX engine
and my code for the app is:
class BoxApp : public Framework_App
{
public:
BoxApp(HINSTANCE hInstance);
~BoxApp();
bool Init();
void OnResize();
void UpdateScene( float dt);
void DrawScene();
void OnMouseDown(WPARAM btnState, int x, int y);
void OnMouseUp(WPARAM btnState, int x, int y);
void OnMouseMove(WPARAM btnState, int x, int y);
private:
void BuildGeometryBuffers();
void BuildFX();
void BuildVertexlayout();
ID3D11Buffer* mBoxVB;
ID3D11Buffer* mBoxIB;
ID3DX11Effect* mFX;
ID3DX11EffectTechnique* mTech;
ID3DX11EffectMatrixVariable* mfxWorldViewProj;
ID3D11InputLayout* inputLayout;
XMFLOAT4X4 mWorld;
XMFLOAT4X4 mView;
XMFLOAT4X4 mProj;
float mTheta, mPhi, mRadius;
POINT mLastMousePos;
};
the problem should be somewhere around these parts, but i can't find them:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE PrevhInstance, PSTR cmdLine, int showCmd){
BoxApp theApp(hInstance);
if (!theApp.Init())
{
return 0;
}
return theApp.App_Run();
}
and:
void BoxApp::BuildFX()
{
DWORD shaderFlags = 0;
ID3D10Blob * compiledShader;
ID3D10Blob * compiledShaderMsgs;
HRESULT hr = D3DX11CompileFromFile((LPSTR)"mColor.fx", 0, 0, 0, "fx_5_0", shaderFlags, 0, 0, &compiledShader, &compiledShaderMsgs, 0);
if (compiledShaderMsgs != 0)
{
MessageBoxA(0, (char*)compiledShaderMsgs->GetBufferPointer(), 0, 0);
ReleaseCOM(compiledShaderMsgs);
}
D3DX11CreateEffectFromMemory(compiledShader->GetBufferPointer(), compiledShader->GetBufferSize(), 0, MainD3DDevice, &mFX);
ReleaseCOM(compiledShader);
mTech = mFX->GetTechniqueByName("ColorTech");
mfxWorldViewProj = mFX->GetVariableByName("gWorldViewProj")->AsMatrix();
}
in the second bit in particulary this: D3DX11CreateEffectFromMemory(compiledShader->GetBufferPointer(), compiledShader->GetBufferSize(), 0, MainD3DDevice, &mFX);
thank you beforehand, i really appreciate it.

Related

OpenGL glUniform1f not updating vertex shader

All the tutorials seem to indicate that I am doing things correctly, the vertex shader works, however it fails to recognize any input changes from the main program through the use of the glUniform1f function. I check glGetError after each line, there are no errors. I check glGetShaderiv and glGetShaderInfoLog, there are no issues. I am testing with OpenGL version 2.1 (unknown profile, but assuming the core profile) as reported by SDL.
#if defined(__WINDOWS__) || defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__TOS_WIN__)\
|| defined(__CYGWIN__)
/* Compiling for Windows */
#ifndef __WINDOWS__
#define __WINDOWS__
#endif
#include <windows.h>
#endif/* Predefined Windows macros */
#include <SDL2/SDL.h>
#include <GL/GL.h>
#include <stdlib.h>
#include <stdio.h>
#include <error.h>
//return type not verified
void glGenBuffers();
void glBindBuffer();
void glBufferData();
unsigned int glCreateShader();
void glShaderSource();
void glCompileShader();
void glGetShaderiv();
void glGetShaderInfoLog();
unsigned int glCreateProgram();
void glAttachShader();
void glLinkProgram();
void glGetProgramiv();
void glGetProgramInfoLog();
void glVertexAttribPointer();
void glEnableVertexAttribArray();
void glUseProgram();
void glDeleteShader();
void glGenVertexArrays();
void glBindVertexArray();
GLint glGetUniformLocation();
void glUniform1f();
void glDeleteProgram();
void glDeleteBuffers();
int fixSDLconsole() {
FILE *console = freopen("stdout.txt", "a",stdout);
if (console == NULL) {return errno;}
console = freopen("stdout.txt", "a",stderr);
if (console == NULL) {return errno;}
return 0;
}
void printGLVersionNumber() {
int majorVersion;
int minorVersion;
int profile;
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &majorVersion);
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minorVersion);
SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile);
fprintf(stderr,"GL version %d.%d ",majorVersion,minorVersion);
switch (profile) {
case SDL_GL_CONTEXT_PROFILE_CORE: fprintf(stderr,"core (%d)\n",profile);break;
case SDL_GL_CONTEXT_PROFILE_COMPATIBILITY: fprintf(stderr,"compatibility (%d)\n",profile);break;
case SDL_GL_CONTEXT_PROFILE_ES: fprintf(stderr,"E.S. (%d)\n",profile);break;
default: fprintf(stderr, "unknown profile: %d\n",profile);break;
}
return;
}
#define checkGlError(label) {int error = glGetError();if (error != GL_NO_ERROR) {error_at_line(0,0,__FILE__,__LINE__,"error=%d", error);goto label;}}
int main(int argc, char **argv) {
SDL_Window *window = NULL;
SDL_GLContext context = NULL;
GLuint verticesGlIds[] = {0,0};
GLuint vertexShaderGlId = 0;
GLuint shaderProgramGlId = 0;
if (fixSDLconsole()) {
return errno;
}
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
error_at_line(1,0,__FILE__,__LINE__,"Unable to initialize SDL: %s",SDL_GetError());
goto error;
}
printGLVersionNumber();
window = SDL_CreateWindow("Window Title",SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED,640,640,SDL_WINDOW_OPENGL);
if (window == NULL) {
error_at_line(0,0,__FILE__,__LINE__,"Could not create window: %s", SDL_GetError());
goto error;
}
context = SDL_GL_CreateContext(window);
if (context == NULL) {
error_at_line(0,0,__FILE__,__LINE__,"Could not create OpenGL context: %s", SDL_GetError());
goto error;
}
glViewport(0,0,640,640);checkGlError(error);
glClearColor(.9f,.9f,.9f,1.f);checkGlError(error);
glEnableClientState(GL_VERTEX_ARRAY);checkGlError(error);
glEnableClientState(GL_COLOR_ARRAY);checkGlError(error);
float vertices[] = {
-.5f,0.f,0.f,
0.f,.5f,0.f,
0.f,-.5f,0.f,
0.f,.5f,0.f,
.5f,.5f,0.f,
0.f,0.f,0.f
};
float colors[] = {
1.f,0.f,0.f,//red
.5f,0.f,0.f,//red
0.f,1.f,0.f,//green
0.f,.5f,0.f,//green
0.f,0.f,1.f,//blue
0.f,0.f,.5f//blue
};
glGenBuffers(2, &verticesGlIds);checkGlError(error);
glBindBuffer(GL_ARRAY_BUFFER, verticesGlIds[0]);checkGlError(error);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);checkGlError(error);
glBindBuffer(GL_ARRAY_BUFFER, verticesGlIds[1]);checkGlError(error);
glBufferData(GL_ARRAY_BUFFER,sizeof(colors),colors, GL_STATIC_DRAW);checkGlError(error);
char *vertexShader =
"#version 120\n"\
"attribute vec3 aPos;\n"\
"uniform float i;\n"\
"void main() {\n"\
"gl_FrontColor=gl_Color;\n"\
"gl_Position = vec4(aPos.x+i/2,aPos.y,aPos.z,1.0);\n"\
"}\n";
vertexShaderGlId = glCreateShader(GL_VERTEX_SHADER);checkGlError(error);
if (vertexShaderGlId == 0) {error_at_line(0,0,__FILE__,__LINE__,"vertex shader could not be created");goto error;}
glShaderSource(vertexShaderGlId, 1, &vertexShader, NULL);checkGlError(error);
glCompileShader(vertexShaderGlId);checkGlError(error);
{
GLint success;
glGetShaderiv(vertexShaderGlId, GL_COMPILE_STATUS, &success);checkGlError(error);
if (success == GL_FALSE) {
char infoLog[512];
glGetShaderInfoLog(vertexShaderGlId, 512, NULL, infoLog);checkGlError(error);
error_at_line(0,0,__FILE__,__LINE__,"Vertex Shader problem: %s", infoLog);
goto error;
}
}
shaderProgramGlId = glCreateProgram();checkGlError(error);
if (shaderProgramGlId == 0) {error_at_line(0,0,__FILE__,__LINE__,"shader program could not be created");goto error;}
glAttachShader(shaderProgramGlId, vertexShaderGlId);checkGlError(error);
glLinkProgram(shaderProgramGlId);checkGlError(error);
{
int success;
glGetProgramiv(shaderProgramGlId, GL_LINK_STATUS, &success);checkGlError(error);
if (!success) {
char infoLog[512];
glGetProgramInfoLog(shaderProgramGlId, 512, NULL, infoLog);checkGlError(error);
error_at_line(0,0,__FILE__,__LINE__,"Shader program problem: %s", infoLog);
}
}
glDeleteShader(vertexShaderGlId);checkGlError(error);
GLint iLocation = glGetUniformLocation(shaderProgramGlId, "i");checkGlError(error);
if (iLocation == -1) {error_at_line(0,0,__FILE__,__LINE__,"uniform i not found in shader");goto error;}
error_at_line(0,0,__FILE__,__LINE__,"iLocation: %d", iLocation);
for (int frame = 0; frame < 100; ++frame) {
glClear(GL_COLOR_BUFFER_BIT);checkGlError(error);
glUseProgram(shaderProgramGlId);checkGlError(error);
glBindBuffer(GL_ARRAY_BUFFER, verticesGlIds[0]); checkGlError(error);
glVertexPointer(3,GL_FLOAT,0,0); checkGlError(error);
glBindBuffer(GL_ARRAY_BUFFER, verticesGlIds[1]); checkGlError(error);
glColorPointer(3,GL_FLOAT,0,0); checkGlError(error);
glUniform1f(iLocation, (float) (frame%2)); checkGlError(error);
glDrawArrays(GL_TRIANGLES, 0,sizeof(vertices)/sizeof(float)/3); checkGlError(error);
glBindBuffer(GL_ARRAY_BUFFER, 0); checkGlError(error);
SDL_GL_SwapWindow(window);
SDL_Delay(100);
}
glDeleteProgram(shaderProgramGlId);
glDeleteShader(vertexShaderGlId);
glDeleteBuffers(sizeof(verticesGlIds)/sizeof(GLuint), verticesGlIds);
SDL_GL_DeleteContext(context);
SDL_Delay(3000);
SDL_DestroyWindow(window);
SDL_Quit();
return EXIT_SUCCESS;
error:
glDeleteProgram(shaderProgramGlId);
glDeleteShader(vertexShaderGlId);
glDeleteBuffers(sizeof(verticesGlIds)/sizeof(GLuint), verticesGlIds);
if (context != NULL) SDL_GL_DeleteContext(context);
if (window != NULL) SDL_DestroyWindow(window);
SDL_Quit();
return EXIT_FAILURE;
}
#if defined(__WINDOWS__)
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
char *argv[1] = {(char *) 0};
return main(0, argv);
}
#endif
note that I am not familiar with OpenGL's extension function loading issues and routines such as SDL's SDL_GL_LoadLibrary and SDL_GL_GetProcAddress I just manually define the method signatures at the top of the file and import GL through the linker. I don't expect this to be an issue but it is the only issue, I am aware of, that I haven't looked into, that may be causing my problems.
So you declare the function like this:
void glUniform1f();
By omitting any parameters, the compiler will assume that all arguments are of type int. For most other GL functions, this works by chance, because those arguments are just integer types in most cases anyway, but for glUniform1f, it will mean that the function argument is converted to integer, but the resulting bit-pattern is implicitely re-interpreted as GLfloat by the function since the actual prototype for glUniform1f is something like this
void glUniform1f(int location, GLfloat value);
note that I am not familiar with OpenGL's extension function loading issues and routines such as SDL's SDL_GL_LoadLibrary and SDL_GL_GetProcAddress I just manually define the method signatures at the top of the file and import GL through the linker.
You shouldn't do this. The GL functions you try to access might not even be exported by the library at all. If you do not want to manually deal with loading every function pointer, you can use one of the existing OpenGL loaders.
gl_Position expects Clip-space coordinates, which are a hiper-cube of size [2w,2w,2w,w].
For vec4(x, y, z, w) if any of the [x,y,z] is outside of [-w,w] range, then the vertex is clipped.
The coordinates will be automatically converted by the GPU to NDC-space x/w, y/w, z/w, 1 (aka "perspective division") before the fragment shader.
Your GLSL code gl_Position = vec4(aPos.x+i/2,aPos.y,aPos.z,1.0); uses the uniform i.
You update it by glUniform1f(iLocation, (float) (frame%2));
First issue is frame%2. Only 0 or 1 is passed to the GPU. With your current vertices data, only two pairs of triangles should be drawn.
Second issue is that frame is a value 0 <= frame < 100. So, if you pass frame instead of frame%2, then for most values aPos.x + i/2 will fall outside the Clip space and you will see only the first two triangle-pairs, or parts of them.

Passing Arguments as Ref type deduction

i my settings looks like:
class Base
{
public:
virtual void eval(const Ref< const Matrix<float,Dynamic,1>> in, Ref<Matrix<float,Dynamic,1>> out) = 0;
virtual void eval( const Ref< const Matrix<float,Dynamic,Dynamic,RowMajor>> inp, Ref<Matrix<float,Dynamic,Dynamic,RowMajor>> out) = 0;
};
class Test : Base
{
public:
void eval(const Ref< const Matrix<float,Dynamic,1>> in, Ref<Matrix<float,Dynamic,1>> out) override
{
out = in;
};
void eval( const Ref< const Matrix<float,Dynamic,Dynamic,RowMajor>> in, Ref<Matrix<float,Dynamic,Dynamic,RowMajor>> out)override
{
for(std::size_t i=0;i<in.rows();i++)
eval( in.row(i).transpose(), out.row(i).transpose() );
};
};
The compiler Error looks like:
In file included from main.cc:2:0:
../tmp.hpp: In member function ‘virtual void eval(Eigen::Ref<const Eigen::Matrix<float, -1, -1, 1> >, Eigen::Ref<Eigen::Matrix<float, -1, -1, 1> >)’:
../tmp.hpp:36:62: error: call of overloaded ‘eval(Eigen::DenseBase<Eigen::Block<const Eigen::Ref<const Eigen::Matrix<float, -1, -1, 1> >, 1, -1, true> >::ConstTransposeReturnType, Eigen::Transpose<Eigen::Block<Eigen::Ref<Eigen::Matrix<float, -1, -1, 1> >, 1, -1, true> >)’ is ambiguous
eval( in.row(i).transpose(), out.row(i).transpose() );
^
../tmp.hpp:25:7: note: candidate: virtual void eval(Eigen::Ref<const Eigen::Matrix<float, -1, 1> >, Eigen::Ref<Eigen::Matrix<float, -1, 1> >)
void eval(const Ref<const Matrix<float, Dynamic, 1>> input,
^
../tmp.hpp:32:7: note: candidate: virtual void eval(Eigen::Ref<const Eigen::Matrix<float, -1, -1, 1> >, Eigen::Ref<Eigen::Matrix<float, -1, -1, 1> >)
void eval(const Ref<const Matrix<float, Dynamic, Dynamic, RowMajor>> input,
^
make: *** [main.o] Error 1
I found this. The types doesn't match, but for me it is not clear how to solve this elegant ( without template's because of the base class )
Indeed, when calling eval with vectors, both overloads can be matched. One solution would be to rename the two overloads to distinct names (e.g., evalVec and evalMat), and add a thin template method dispatching to the correct one:
template<typename A, typename B>
void eval(const MatrixBase<A> &a, MatrixBase<B> &b,
typename enable_if<A::IsVectorAtCompile,void*>::type = 0) {
this->evalVec(a.derived(),b.derived());
}
template<typename A, typename B>
void eval(const MatrixBase<A> &a, MatrixBase<B> &b,
typename enable_if<!A::IsVectorAtCompile,void*>::type = 0) {
this->evalMat(a.derived(),b.derived());
}

"Makes Pointer from Integer without a Cast" - How do I satisfy GCC?

I'm writing my first X11 applications in C and I've run into a major problem while trying to retrieve the size of my applications window.
temp.c:30:2 warning: passing argument 3 of 'XGetGeometry' makes pointer from integer without a cast
I know this is just a warning, but it still results in a segfault which isn't fun. Here is my code:
static void loop();
static void initialize();
static void cleanUp();
static void run();
/* Variables */
static int screenNumber;
unsigned long White;
unsigned long Black;
long eventMask;
static Display *currentDisplay;
static Window currentWindow;
static unsigned int windowWidth;
static unsigned int windowHeight;
static GC graphicsController;
static XEvent XEvents;
void loop() {
XGetGeometry(currentDisplay, currentWindow, DefaultRootWindow(currentDisplay), NULL, NULL, &windowWidth, &windowHeight, NULL, NULL);
XDrawLine(currentDisplay, currentWindow, graphicsController, 0, 0, (int)windowWidth, (int)windowHeight);
XDrawLine(currentDisplay, currentWindow, graphicsController, 0, (int)windowHeight, (int)windowWidth, 0);
}
void initialize() {
currentDisplay = XOpenDisplay(NULL);
screenNumber = DefaultScreen(currentDisplay);
White = WhitePixel(currentDisplay, screenNumber);
Black = BlackPixel(currentDisplay, screenNumber);
currentWindow = XCreateSimpleWindow( currentDisplay,
DefaultRootWindow(currentDisplay),
0, 0,
500, 500,
0, Black,
White);
XMapWindow(currentDisplay, currentWindow);
XStoreName(currentDisplay, currentWindow, "rGot - X11");
eventMask = StructureNotifyMask;
XSelectInput(currentDisplay, currentWindow, eventMask);
do{
XNextEvent(currentDisplay, &XEvents);
}while(XEvents.type != MapNotify);
graphicsController = XCreateGC(currentDisplay, currentWindow, 0, NULL);
XSetForeground(currentDisplay, graphicsController, Black);
}
void run() {
eventMask = ButtonPressMask|ButtonReleaseMask;
XSelectInput(currentDisplay, currentWindow, eventMask);
do{
XNextEvent(currentDisplay, &XEvents);
loop();
}while(1==1);
}
void cleanUp() {
XDestroyWindow(currentDisplay, currentWindow);
XCloseDisplay(currentDisplay);
}
int main(){
initialize();
run();
cleanUp();
return 0;
}
I know I'm doing something wrong with my pointers 'n such, but I'm fairly new to this... Here is my setup:
Ubuntu 12.04 LTS
Compiling with: gcc tempc -o temp -lX11
For those finding this later - my initial attempts to utilize XGetGeometry were completely wrong!
To correctly use it, I had to do the following:
XGetGeometry(currentDisplay, currentWindow, &currentRoot, &windowOffsetX, &windowOffsetY, &windowWidth, &windowHeight, &windowBorderWidth, &windowDepth);
This was based off of my findings here.
Based on the docs for the two functions, DefaultRootWindow() returns a Window while XGetGeometry() expects a Window* for the third argument. So as the warning says, you're passing a normal type where a pointer to that type is expected.

Errors C2059 and C2061 in C language [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Why does VS2010 give syntax errors when syntax is correct?
I'm trying to develop a kind of Windows 32 service in C language, using Visual Studio 2010.
I created a new project, and inserted .c files :
main.c
service.c
misc.c
I also have two header files :
myerrors.h
my.h
Here's the code I have (be aware that it's just a draft).
main.c :
#include <Windows.h>
#include <stdlib.h>
#include <stdio.h>
#include "stdafx.h"
#include "my.h"
#include "myerrors.h"
static int parse_args(int ac, char **av)
{
int i = 0;
while (++i < ac)
if (strcmp(av[i], "-i") && !InstallMyService())
return false;
else if (strcmp(av[i], "-d") && !UninstallMyService())
return false;
else if (strcmp(av[i], "-p"))
if (!av[i + 1])
return false;
else
{
if (!InsertPathInRegistry(av[i + 1]))
return false;
i++;
}
else
return false;
return true;
}
int main(int ac, char **av)
{
HANDLE hLogFile;
if ((hLogFile = CreateFile(LOG_FILE_PATH, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE)
aff_error(CANT_CREATE_FILE);
if (ac > 1)
{
if (!parse_args(ac, av))
{
aff_error(BAD_ARGUMENTS);
return EXIT_FAILURE;
}
}
else
{
SERVICE_TABLE_ENTRY DispatchTable[] = {{DC_SERVICE_NAME, ServiceMain}, {NULL, NULL}};
StartServiceCtrlDispatcher(DispatchTable);
}
getchar();
if (!CloseHandle(hLogFile))
aff_error(CLOSE_FILE_FAILED);
return EXIT_SUCCESS;
}
misc.c :
#include <Windows.h>
#include <stdio.h>
#include "my.h"
#include "myerrors.h"
void aff_error(char *error_str)
{
fprintf(stderr, "ERROR: %s\n", error_str);
}
bool InsertPathInRegistry(char *path)
{
printf("LOG: Inserting %s as ", path);
}
void WriteInLogFile(HANDLE hLogFile, char *log_string)
{
printf("WriteInLogFile function");
}
service.c :
#include <Windows.h>
#include "my.h"
bool InstallMyService()
{
return true;
}
bool UninstallMyService()
{
return true;
}
void WINAPI ServiceCtrlHandler(DWORD Opcode)
{
}
void WINAPI ServiceMain(DWORD ac, LPTSTR *av)
{
}
My headers are just some function declarations and macros such as :
# define DC_SERVICE_NAME "MyService"
/* MISC functions */
void aff_error(char *error_str);
my.h
#ifndef _MY_H_
# define _MY_H_
#include <Windows.h>
#include <strsafe.h>
/* Macros */
# define LOG_FILE_PATH "c:\\my_log_file.txt"
# define DC_SERVICE_NAME "MyService"
/* MISC functions */
void aff_error(char *error_str);
/* SERVICE functions */
void WINAPI ServiceMain(DWORD ac, LPTSTR *av);
bool InstallMyService();
bool UninstallMyService();
bool InsertPathInRegistry(char *path);
void WINAPI ServiceCtrlHandler(DWORD Opcode);
#endif /*!MY_H_ */
While trying to compile the project, i got some weird errors :
my.h(19): error C2061: syntax error : identifier 'InstallMyService'
my.h(19): error C2059: syntax error : ';'
my.h(19): error C2059: syntax error : ')'
Or :
my.h(21): error C2061: syntax error : identifier 'InsertPathInRegistry'
my.h(21): error C2059: syntax error : ';'
my.h(21): error C2059: syntax error : 'type'
I checked on some forums that says those errors are commonly errors with includes badly placed, but I don't really know in this case, I don't think I made mistakes with includes...
Can anyone illuminate me ?
Thanks.
bool is not a data type in ANSI C. It is a data type in the C99 version of the language, only if <stdbool.h> is included, but Visual Studio does not support C99, only C89 (C99 also adds the _Bool data type, which can be used without including any headers).
I suggest you replace bool with another type such as int, or use a typedef to alias it with int or unsigned char or something.

C2061 Syntax Error (identifier)

1>cb.c(51): error C2061: syntax error : identifier 'SaveConfiguration'
1>cb.c(51): error C2059: syntax error : ';'
1>cb.c(51): error C2059: syntax error : 'type'
1>cb.c(52): error C2061: syntax error : identifier 'LoadConfiguration'
1>cb.c(52): error C2059: syntax error : ';'
1>cb.c(52): error C2059: syntax error : 'type'
1>cb.c(122): error C2061: syntax error : identifier 'SaveConfiguration'
1>cb.c(122): error C2059: syntax error : ';'
1>cb.c(122): error C2059: syntax error : 'type'
1>cb.c(127): error C2061: syntax error : identifier 'LoadConfiguration'
1>cb.c(127): error C2059: syntax error : ';'
1>cb.c(127): error C2059: syntax error : 'type'
1>
1>Build FAILED.
It's just a single .c file in the project. Here's the code:
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <process.h>
#include <tchar.h>
typedef struct _Configuration
{
int KeyActivate;
int BlockWidth;
int BlockHeight;
double HueStart;
double HueEnd;
double SaturationStart;
double SaturationEnd;
double ValueStart;
double ValueEnd;
} Configuration;
typedef struct _DIBSection
{
HDC ScreenDC;
HDC WindowDC;
HDC MemoryDC;
HBITMAP ScreenBMPHandle;
BITMAP ScreenBMP;
} DIBSection;
typedef struct _Thread
{
HANDLE Handle;
unsigned Id;
} Thread;
typedef struct _Window
{
HANDLE Handle;
HDC DC;
int Width;
int Height;
int Top;
int Left;
} Window;
__declspec ( dllexport ) int Initialize ( void );
unsigned __stdcall Start ( void * Arguments );
void LoadDefaultConfiguration ( Configuration * Config );
bool SaveConfiguration ( Configuration * Config, LPTSTR FilePath );
bool LoadConfiguration ( Configuration * Config, LPTSTR FilePath );
Thread MainThread;
Window Screen;
Configuration Settings;
BOOL WINAPI DllMain ( HINSTANCE Instance, DWORD Reason, LPVOID Reserved )
{
switch ( Reason )
{
case DLL_PROCESS_ATTACH:
// TODO: Load settings from file
LoadDefaultConfiguration ( & Settings );
// Create main thread
MainThread.Handle = (HANDLE) _beginthreadex (
NULL,
0,
Start,
NULL,
0,
& MainThread.Id
);
if ( MainThread.Handle )
{
SetThreadPriority ( MainThread.Handle, THREAD_PRIORITY_BELOW_NORMAL );
}
else
{
MessageBox ( NULL, L"Unable to create main thread; exiting", L"Error", MB_OK );
ExitProcess ( 0 );
}
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
__declspec ( dllexport ) int Initialize ( void )
{
return 1;
}
unsigned __stdcall Start ( void * Arguments )
{
return 1;
}
void LoadDefaultConfiguration ( Configuration * Config )
{
Config->BlockHeight = 50;
Config->BlockWidth = 100;
Config->HueEnd = 0.00;
Config->HueStart = 0.00;
Config->KeyActivate = VK_SHIFT;
Config->SaturationEnd = 0.00;
Config->SaturationStart = 0.00;
Config->ValueEnd = 0.00;
Config->ValueStart = 0.00;
}
bool SaveConfiguration ( Configuration * Config, LPTSTR FilePath )
{
return true;
}
bool LoadConfiguration ( Configuration * Config, LPTSTR FilePath )
{
return true;
}
Line 51 is
bool SaveConfiguration ( Configuration * Config, LPTSTR FilePath );
bool is not a C type.
I do suspect BOOL is defined somewhere.
Same goes for the usage of true and false.
Actually, bool is a valid type (well, a macro actually) in the C99 standard, assuming you are using a recent compiler. You need to add:
#include <stdbool.h>
Note that bool is not valid in the older ANSI, C89, C90 etc variants of the C standards.
As highlighted by JeremyP in the comments, Microsoft's C compiler still lacks proper support for C99 features.
Which leaves three alternatives:
Treat it as C++, not C; because C++ has bool as a built-in type
Create your own bool implementation
Re-write the code to avoid using bool
For option 2 something like this would work, but it's an ugly work-around:
typedef short bool;
#define true 1
#define false 0

Resources