Tag: compiler errors

OS X上的Pthread和gcc编译问题

我有一个在Linux上编译好的脚本(Ubuntu 11.04),但在OS X(Lion)上没有。 gcc -pthread -o hw1 hw1.c hw1.c:22: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘barr’ hw1.c: In function ‘__syncthreads’: hw1.c:53: error: ‘barr’ undeclared (first use in this function) hw1.c:53: error: (Each undeclared identifier is reported only once hw1.c:53: error: for each function it appears in.) hw1.c:54: error: ‘PTHREAD_BARRIER_SERIAL_THREAD’ undeclared (first use […]

Linux中的蓝牙编程 – 交叉编译问题

我安装了 sudo apt-get install libbluetooth-dev 在我的环境中拥有蓝牙套件。 因此,使用以下命令可以使用gcc成功编译蓝牙代码。 gcc -o bt bt.c -lbluetooth 但是,当我尝试使用交叉编译器来编译源代码时 $CC -o bt2 bt.c -lbluetooth 我得到了致命的错误: fatal error: bluetooth/bluetooth.h: No such file or directory compilation terminated 有什么我做错了或者我需要将这个库链接到这个交叉编译器吗? 谢谢

C编译器无法在SUA / Interix上创建可执行文件

每当我尝试在Windows上使用Interix的GCC构建应用程序时,会发生以下情况: /tmp/grep-2.5.4-src/build$ ../configure –build=x86_64-pc-interix6 checking for a BSD-compatible install… /bin/install -c checking whether build environment is sane… yes checking for a thread-safe mkdir -p… ../install-sh -c -d checking for gawk… gawk checking whether make sets $(MAKE)… yes checking build system type… x86_64-pc-interix6 checking host system type… x86_64-pc-interix6 checking for gawk… (cached) gawk checking for gcc… […]

隐藏C结构定义

这是我的设置: 在public.h: #ifndef PUBLIC_H_ #define PUBLIC_H_ #include “func.h” /*extern typedef struct _my_private_struct PRIVATE_;*/ typedef struct _my_private_struct PRIVATE_; /* Thanks to larsmans and Simon Richter */ #endif 在struct.h中 #ifndef STRUCT_H_ #define STRUCT_H_ struct _my_private_struct { int i; }; #endif 在func.h中: #ifndef FUNC_H_ #define FUNC_H_ #include “struct.h” /* typedef struct _my_private_struct PRIVATE_; */ extern PRIVATE_ * get_new(int); […]

错误:在文件范围内修改了’d’

代码1: – int size; struct demo { int a; }; int main() { scanf(“%d”,&size); struct demo d[size]; return 0; } 这段代码工作正常。 代码2: – int size; struct demo { int a; }; int main() { scanf(“%d”,&size); return 0; } struct demo d[size]; 此代码显示错误: – error : variably modified ‘d’ at file scope 为什么这样的错误会出现在Code 2而Code 1运行正常?

什么时候const被认为是一个常量?

在阅读stackoverflow中的一些问题和答案时,我遇到了这个问题 我试图理解它,但答案很难理解,特别是像这样的术语 静态存储持续时间 在翻译阶段无法评估表达式 等等… 此外,我认为常量总是常量(这是我从学校学到的) 有人可以让它有点容易理解吗?

obfile的Makefile C子目录规则

我运行一个简单的Makefile没有问题: CC=gcc CFLAGS= -std=c99 -ggdb -Wall -I. DEPS = hellomake.h OBJ = hellomake.o hellofunc.o %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) hellomake: $(OBJ) gcc -o $@ $^ $(CFLAGS) 这些文件位于主项目的目录中: ./project/Makefile ./project/hellomake.c ./project/hellomake.h 然后我尝试组织文件,并把事情如下: ./project/Makefile ./project/src/hellomake.c ./project/include/hellomake.h 和额外的子目录目录: ./project/lib ./project/obj 然后是新版本的Makefile: IDIR =include CC=gcc CFLAGS= -std=c99 -ggdb -Wall -I$(IDIR) ODIR=obj LDIR =lib LIBS=-lm _DEPS […]

Cplex库gcc编译链接错误

gcc -I/opt/cplex-studio-125/cplex/include -lcplex -L/opt/cplex-studio-125/cplex/lib/x86-64_sles10_4.1/static_pic mipex1.c 我正在尝试从cplex编译一个例子。 -I选择没问题。 -L选项似乎已损坏,因为它无法找到函数名称。 错误在哪里? 在特定的链接中有一个libcplex.a 。 /tmp/ccf5sKky.o: In function `main’: mipex1.c:(.text+0x9f): undefined reference to `CPXopenCPLEX’ mipex1.c:(.text+0xee): undefined reference to `CPXgeterrorstring’ mipex1.c:(.text+0x125): undefined reference to `CPXsetintparam’ mipex1.c:(.text+0x222): undefined reference to `CPXcreateprob’ mipex1.c:(.text+0x2e1): undefined reference to `CPXcopylp’ mipex1.c:(.text+0x334): undefined reference to `CPXcopyctype’ mipex1.c:(.text+0x380): undefined reference to `CPXmipopt’ mipex1.c:(.text+0x3cc): undefined reference to `CPXgetstat’ […]

这个错误是什么意思:`somefile.c:200:错误:1032字节的帧大小大于1024字节`?

在制作期间,我发现了一个错误: cc1: warnings being treated as errors somefile.c:200: error: the frame size of 1032 bytes is larger than 1024 bytes 行号指向ac函数的右括号,其具有如下签名: void trace(SomeEnum1 p1, SomeEnum2 p2, char* format, …) { char strBuffer[1024]; … 该函数将一些内容打印到缓冲区中。 任何人都知道这种类型的错误通常意味着什么?

GCC linaro编译器抛出错误“unknown type name size_t”

我正在使用GCC Linaro编译器来编译我的代码。 它从libio.h抛出错误unknown type name size_t 。 它包含在stdio.h 。 在我的代码中,我只包括stdio.h 。 可以请任何人如何解决此错误。