编译一个DLL文件时出的错,
d:\program files\microsoft visual studio\vc98\include\excpt.h(41) : error C2143: syntax error : missing ';' before 'string'
d:\program files\microsoft visual studio\vc98\include\excpt.h(41) : fatal error C1004: unexpected end of file foundexcpt.h的内容如下(截取)#ifdef  __cplusplus
extern "C" {
#endif/* Define _CRTIMP */
#ifndef _CRTIMP     //错误箭头指向此处
#ifdef  _DLL
#define _CRTIMP __declspec(dllimport)
#else   /* ndef _DLL */
#define _CRTIMP
#endif  /* _DLL */
#endif  /* _CRTIMP */
/* Define __cdecl for non-Microsoft compilers */我这个DLL程序是照书做的,特别简单!一字不差啊,真是郁闷!
.cpp文件如下:#define DLL1_API _declspec(dllexport)
#include "Dll1.h"
#include <Windows.h>
#include <stdio.h>int add(int a, int b)
{
return a+b;
}
int subtract(int a, int b)
{
return a-b;
}void Point::output(int x,int y)
{
HWND hwnd=GetForegroundWindow();
HDC hdc=GetDC(hwnd);
char buf[20];
memset(buf,0,20);
sprintf(buf,"x=%d,y=%d",x,y);
TextOut(hdc,0,0,buf,strlen(buf));
ReleaseDC(hwnd,hdc);
}
dll1.h文件如下:#ifdef DLL1_API
#else
#define DLL1_API _declspec(dllimport)
#endifDLL1_API int add(int a,int b);
DLL1_API int subtract(int a,int b);class DLL1_API Point
{
public:
void output(int x,int y);
}哪位高手大哥知道,请赐教

解决方案 »

  1.   

    #include "Dll1.h"
    #include <Windows.h>
    #include <stdio.h>把这个调整一下
    #include <stdio.h>
    #include <windows.h>
    #include "dll1.h"如果还不行,加上下面两条
    #inlucde <string>
    using namespace std;
      

  2.   

    我映像中,windows.h要放在最前面,这样才不会出奇怪的错误
      

  3.   

    那几个头文件顺序改了多种也不行,错误还多了,变成几十个了,都是报头文件的中的错误.
    谢谢黑暗之光各位大侠,但加那两条也不行,windows.h放在最前也不行。
    我这是照视频教学做的,眼瞅着是成功的,非常简单的小程序,肯定不会有错。太奇怪了!