   [solved] Making a DLL, I'm going insane
  Hi, I'm trying to make a very simple test DLL from the DLL template in Dev-C++. The only thing I've changed is some of the parameter names to match my style, everything else is exactly like the template code. I keep getting syntax errors though, both in Dev-C++ and VCExpress.DLL.c#include "DLL.h"#include <windows.h>#include <stdio.h>#include <stdlib.h>DLLIMPORT void HelloWorld(){    MessageBox( 0, "Hello World from DLL!\n", "Hi", MB_ICONINFORMATION );}BOOL APIENTRY DllMain( HINSTANCE Instance, DWORD Reason, LPVOID Reserved ){switch( Reason ){case DLL_PROCESS_ATTACH:break;case DLL_PROCESS_DETACH:break;case DLL_THREAD_ATTACH:break;case DLL_THREAD_DETACH:break;}return TRUE;}DLL.h#ifndef _DLL_H_#define _DLL_H_//#if BUILDING_DLL#define DLLIMPORT __declspec (dllexport)//#else //#define DLLIMPORT __declspec (dllimport)//#endifclass DLLIMPORT DllClass{  public:DllClass();virtual ~DllClass(void);};#endif In Dev-C++ I get the error:"10 DLL.h syntax error before "DllClass" "In VCExpress the errors I get:"DLL.h(11) : error C2054: expected '(' to follow 'class'""DLL.h(12) : error C2085: 'DllClass' : not in formal parameter list""DLL.h(12) : error C2143: syntax error : missing ';' before '{'"I've spent far too much time trying to figure this out and I don't understand why code strait from the template won't compile. Any help is appreciated.[Edited by - Scet on July 23, 2006 11:17:59 AM]
  Compiling a class in a .c file, and hence using the C compiler? :P   ;  For visual studio, change your file name from 'dll.c' to 'dll.cpp'.Don't ask why, it some kind of very old magic :)   ;  what if you change DLLIMPORT to something else like MYDLLAPI? some of the windows headers oftentimes define their own DLLIMPORT macro... i'm suprised you aren't getting any macro redefinition errors. doing a macro like that you should never include IMPORT or EXPORT words in them because it changes depending on what you are building so having it say IMPORT all the time is misleading and the way you have can conflict with other predefined macros.Y-Go   ;  EDIT:ha ha ha now that those other guys mentioned it, yeah... a class in a C file lol (though i'd still recommend changing that macro you're using)?YG   ;Quote:Original post by mattdCompiling a class in a .c file, and hence using the C compiler? :PIt's offical, I'm a complete idiot.Thanks guys :(