我正在尝试使用以下代码:
bool SaveBMPFile(char *filename, HBITMAP bitmap, HDC bitmapDC, int width, int height);
bool ScreenCapture(int x, int y, int width, int height, char *filename){
// get a DC compat. w/ the screen
HDC hDc = CreateCompatibleDC(0);
// make a bmp in memory to store the capture in
HBITMAP hBmp = CreateCompatibleBitmap(GetDC(0), width, height);
// join em up
SelectObject(hDc, hBmp);
// copy from the screen to my bitmap
BitBlt(hDc, 0, 0, width, height, GetDC(0), x, y, SRCCOPY);
// save my bitmap
bool ret = SaveBMPFile(filename, hBmp, hDc, width, height);
// free the bitmap memory
DeleteObject(hBmp);
return ret;
}它抛出以下错误:
bot.c|185|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'SaveBMPFile'|
bot.c|187|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ScreenCapture'|我能做什么?尝试不同的代码将不起作用,并尝试使用Gdi+-也错误。
发布于 2012-10-17 03:51:26
我想你要错过#include <stdbool.h>了。
bool不是C中的原语类型。必须包含<stdbool.h>标头才能获得其定义。
发布于 2012-10-17 03:51:50
很可能您的错误实际上发生在您所显示的代码之前。错误消息说它需要这些东西中的一个;因此,在您所显示的代码片段之前,很可能有一行没有以分号(;)结束,或者一个函数没有以右大括号(})结束。一件事是确保你没有把它粘贴到另一个函数的中间;你不能在C中嵌套函数。
https://stackoverflow.com/questions/12922348
复制相似问题