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) 码:
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'?
struct S {
int a;
};
int a = ((struct S) {8}).a;
Run Code Online (Sandbox Code Playgroud)
编译器报告错误"初始化元素不是编译时常量",为什么?
AFAIK,BIOS大小限制为段大小(0xFFFF)。但是,如今许多BIOS都超过了64KB,通常超过10MB。它怎么做呢?