小编noi*_*put的帖子

我应该释放setlocale返回的指针吗?

int main(int argc, char *argv[])
{
    char *ret = setlocale(LC_ALL, NULL);
    // should I free 'ret' ???
    // free(ret);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我已经在Linux和OS X 10.10上尝试过,在Linux上,我不能称之为'免费',但在OS X上,如果我不调用'free',valgrind会抱怨内存泄漏.

==62032== Memcheck, a memory error detector
==62032== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==62032== Using Valgrind-3.11.0.SVN and LibVEX; rerun with -h for copyright info
==62032== Command: ./a.out
==62032== 
--62032-- ./a.out:
--62032-- dSYM directory is missing; consider using --dsymutil=yes
==62032== 
==62032== HEAP SUMMARY:
==62032==     in use at exit: 129,789 bytes …
Run Code Online (Sandbox Code Playgroud)

c linux macos valgrind setlocale

7
推荐指数
1
解决办法
505
查看次数

使用超出范围的声明

码:

void foo() {
    extern int a;
    extern void b(int);
}

void bar() {
    b(9); // ok, warning: use of out-of-scope declaration of 'b'
    a=9; // error: use of undeclared identifier 'a'
}
Run Code Online (Sandbox Code Playgroud)

为什么编译器不只是发出警告use of out-of-scope declaration of 'a'

c gcc clang

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

如何让gcc跳过预处理?

我想做一些测试,并希望将输入文件直接传递给 c 编译器,而不是预先处理。我怎样才能做到这一点?谢谢!

c clang

3
推荐指数
1
解决办法
936
查看次数

struct member'Instrateizer元素不是编译时常量'

struct S {
   int a;
};

int a = ((struct S) {8}).a;
Run Code Online (Sandbox Code Playgroud)

编译器报告错误"初始化元素不是编译时常量",为什么?

c struct initializer

2
推荐指数
1
解决办法
4957
查看次数

今天的BIOS如何超过64KB?

AFAIK,BIOS大小限制为段大小(0xFFFF)。但是,如今许多BIOS都超过了64KB,通常超过10MB。它怎么做呢?

x86 bios

2
推荐指数
1
解决办法
64
查看次数

标签 统计

c ×4

clang ×2

bios ×1

gcc ×1

initializer ×1

linux ×1

macos ×1

setlocale ×1

struct ×1

valgrind ×1

x86 ×1