我一直试图在过去几个小时内调试此错误,但无济于事 使用以下批处理文件构建程序时,
REM Build process for text editor
@echo off
pushd build
cl /Zi /MDd /IC:\Users\Giovanni\dev_lib\SDL2-2.0.4\include /I"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include" /I"C:\Program Files (x86)\Windows Kits\8.1\Include\shared" ..\*.c /link /NODEFAULTLIB:msvcrt.lib /ENTRY:mainCRTStartup /SUBSYSTEM:console /LIBPATH:C:\Users\Giovanni\dev_lib\SDL2-2.0.4\lib\x64 /LIBPATH:C:\Users\Giovanni\dev_lib\SDL2_image-2.0.1\lib\x64 SDL2.lib SDL2main.lib SDL2_image.lib /out:text_editor.exe
popd
我在CMD中收到以下错误消息:
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
main.c
..\main.c(36) : error C2143: syntax error : missing ')' before 'type'
我的全班都在这里:
#include <assert.h>
#include <stdio.h>
#include <SDL.h>
#define BOOL u32
#define TRUE 1
#define FALSE 0
#define SCREEN_WIDTH 1024
#define SCREEN_HEIGHT 576
typedef Uint32 u32;
typedef Uint64 u64;
typedef Sint32 i32;
typedef Sint64 i64;
int main (int argc, char *argv[]) {
SDL_Init(SDL_INIT_VIDEO);
SDL_Window *win = SDL_CreateWindow("Text Editor",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
SCREEN_WIDTH, SCREEN_HEIGHT, 0);
assert(win);
SDL_Renderer *renderer = SDL_CreateRenderer(win, 0, SDL_RENDERER_SOFTWARE);
assert(renderer);
SDL_Texture *screen = SDL_CreateTexture(renderer,
SDL_PIXELFORMAT_RGB888,
SDL_TEXTUREACCESS_STREAMING,
SCREEN_WIDTH, SCREEN_HEIGHT);
assert(screen);
u32 *screen_pixels = (u32*) calloc(SCREEN_WIDTH * SCREEN_HEIGHT, sizeOf(u32));
assert(screen_pixels);
SDL_Delay(3000);
}
(它只有40行)
如果你能解释我做错了什么(我是C的新手),那将非常有帮助!谢谢!
答案 0 :(得分:2)
该消息表明错误在第36行。
..\main.c(36) : error C2143:
我相信这是第36行:
u32 *screen_pixels = (u32*) calloc(SCREEN_WIDTH * SCREEN_HEIGHT,sizeOf(u32));
你看到有任何错别字吗?你能识别每一个变量并在该行上进行调用吗?
不同
sizeof
与sizeOf
答案 1 :(得分:0)
我没有运行Windows,但这看起来很奇怪:
u32 *screen_pixels = (u32*) calloc(SCREEN_WIDTH * SCREEN_HEIGHT, sizeOf(u32));
您是否尝试过sizeof
没有资金O
?