Tag: gcc

gcc中有128位整数吗?

我想要128位整数,因为我想存储两个64位数的乘法结果。 在gcc 4.4及以上版本中有没有这样的东西?

使用gcc编译c程序时出现冲突类型错误

我试着用gcc编译以下程序。 0 #include 1 2 main () 3 4 { 5 char my_string[] = “hello there”; 6 7 my_print (my_string); 8 my_print2 (my_string); 9} 10 11 void my_print (char *string) 12 { 13 printf (“The string is %s\n”, string); 14 } 15 16 void my_print2 (char *string) 17 { 18 char *string2; 19 int size, […]

powfunction在这里发生了什么?

我在这里看到了各种答案,描述了C函数中的pow函数的奇怪行为。 但我在这里问一些不同的东西。 在下面的代码中,我初始化了int x = pow(10,2)和int y = pow(10,n) (int n = 2) 。 在第一种情况下,当我打印结果时,它显示100而在另一种情况下,它显示为99 。 我知道pow返回double并且在int存储时会被截断,但我想问为什么输出会有所不同。 CODE1 #include #include int main() { int n = 2; int x; int y; x = pow(10,2); //Printing Gives Output 100 y = pow(10,n); //Printing Gives Output 99 printf(“%d %d” , x , y); } Output : 100 […]

pthread_mutex_lock是否包含内存栅栏指令?

pthread_mutex_lock和pthread_mutex_unlock函数是否调用内存栅栏/屏障指令? 或者像compare_and_swap暗示那样的低级指令是否有内存障碍?

如何将变量放在内存中的给定绝对地址(使用GCC)

RealView ARM C编译器支持使用at(address)的变量属性将变量放在给定的内存地址: int var __attribute__((at(0x40001000))); var = 4; // changes the memory located at 0x40001000 GCC是否具有类似的变量属性?

C中的严格别名

关于类型惩罚的问题:为什么这段代码会破坏严格的别名规则: int main() { int a = 1; short j; printf(“%i\n”, j = *((short*)&a)); return 0; } 这不是: int main() { int a = 1; short j; int *p; p=&a; printf(“%i\n”, j = *((short*)p)); return 0; } 由gcc -fstrict-aliasing构建。 谢谢!

/ usr / bin / ld:使用makefile编译时找不到-lc

首先:我有一个标题(event.h),一个名为event.c的程序,以及主程序main.c. 这个程序将被编译,首先生成一个目标程序(event.o),然后在一个单独的文件夹中生成一个静态库(libevent.a),然后生成可执行程序work1.exe 为此,我创建了这个makefile: work1 : main.c libevent.a gcc -static main.c -L./lib -levent -o work1 -Wall event.o: event.c gcc -c event.c -Wall libevent.a: event.o ar rcs lib/libevento.a event.o clean: rm work1 *.o 执行makefile的结果导致此错误: $ make gcc -c event.c -Wall ar rcs lib/libevent.a event.o gcc -static main.c -L./lib -levent -o work1 -Wall /usr/bin/ld: cannot find -lc collect2: […]

在OS X Yosemite上使用gcc编译器编译OpenMP程序

$ gcc 12.c -fopenmp 12.c:9:9: fatal error: ‘omp.h’ file not found #include ^ 1 error generated. 在编译openMP程序时,我得到了上述错误。 我正在使用OS X Yosemite。 我首先尝试通过在终端中输入gcc来安装本机gcc编译器,后来又下载了Xcode我仍然遇到了同样的错误。 然后我下载了gcc: $ brew install gcc 我仍然得到同样的错误。 我确实尝试更改编译器路径,它仍显示: $ which gcc /usr/bin/gcc 那么如何用gcc编译程序呢?

gcc没有警告未初始化的变量

以下代码具有可能未初始化的变量。 似乎gcc应该生成警告,但不是: $ cat ac int foo(int b) { int a; if (b) a = 1; return a; } $ gcc-4.7 -c -Wall -Wmaybe-uninitialized -o ao ./ac $ gcc-4.7 -v Using built-in specs. COLLECT_GCC=gcc-4.7 COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v –with-pkgversion=’Ubuntu/Linaro 4.7.3-2ubuntu1~12.04′ –with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs –enable-languages=c,c++,go,fortran,objc,obj-c++ –prefix=/usr –program-suffix=-4.7 –enable-shared –enable-linker-build-id –libexecdir=/usr/lib –without-included-gettext –enable-threads=posix –with-gxx-include-dir=/usr/include/c++/4.7 –libdir=/usr/lib –enable-nls […]

GCC:数组类型具有不完整的元素类型

我已经声明了一个结构,我尝试将这些结构的数组(以及双数组和一个整数)传递给一个函数。 当我编译它时,我从gcc得到一个“数组类型具有不完整的元素类型”消息。 我如何将结构传递给函数我有什么问题? typedef struct graph_node { int X; int Y; int active; } g_node; void print_graph(g_node graph_node[], double weight[][], int nodes); 我也试过了struct g_node graph_node[] ,但我得到了同样的东西。