小编Eag*_*gle的帖子

openmp 是否分配内存并在之后全部释放

openmp 是否分配内存并释放所有内存?因为我运行 valgrind,并释放了我所有的列表。我 malloc 的所有东西,我都释放了。

==11442== HEAP SUMMARY:
==11442==     in use at exit: 192 bytes in 1 blocks
==11442==   total heap usage: 2,001 allocs, 2,000 frees, 2,917,280 bytes allocated
==11442== 
==11442== LEAK SUMMARY:
==11442==    definitely lost: 0 bytes in 0 blocks
==11442==    indirectly lost: 0 bytes in 0 blocks
==11442==      possibly lost: 0 bytes in 0 blocks
==11442==    still reachable: 192 bytes in 1 blocks
==11442==         suppressed: 0 bytes in 0 blocks
Run Code Online (Sandbox Code Playgroud)

如果不是,为什么一个块中仍然存在内存泄漏?

这是我的代码:

#include <stdio.h>
#include <stdlib.h>
#include <time.h> …
Run Code Online (Sandbox Code Playgroud)

c malloc valgrind memory-leaks openmp

5
推荐指数
1
解决办法
3687
查看次数

在gcc中使用内置函数__builtin_add_overflow_p

我想知道如何使用这个函数,因为我这样做时出错了:

#define INT_ADD_OVERFLOW_P(a, b) \
__builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0);
#include <stdio.h>
#include <assert.h>
__int main()
{
    int x1 = -1073741826;
    int y1 = -1073741826;
    int z1 = x1+y1; 
    INT_ADD_OVERFLOW_P ( x1,  y1);
    printf("%d\n",z1);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

Compile_OUTPUT:

gcc -c -Wall -D DEBUG  tempFile.c
gcc tempFile.o -o tempFile
Makefile:8: recipe for target 'tempFile' failed//new error after update
Run Code Online (Sandbox Code Playgroud)

Compile_ERROR:

tempFile.c: In function ‘main’:
tempFile.c:10:1: warning: implicit declaration of function        ‘__builtin_add_overflow_p’ [-Wimplicit-function-declaration]
tempFile.o: In function `main':
tempFile.c:(.text+0x44): undefined reference …
Run Code Online (Sandbox Code Playgroud)

c gcc overflow built-in

5
推荐指数
1
解决办法
5718
查看次数

将int数组转换为c中的int值

我有一个整数数组

int number[] = {1,2,3,4};
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能得到int x = 1234?我需要有它的交流版本.

c

4
推荐指数
1
解决办法
162
查看次数

标签 统计

c ×3

built-in ×1

gcc ×1

malloc ×1

memory-leaks ×1

openmp ×1

overflow ×1

valgrind ×1