标签: libc

Windows下的MSVCRT是否像*nix下的glibc(libc)?

我经常遇到与程序可执行文件捆绑在一起的MSVCRT(或更新的等价物)的Windows程序.在典型的PC上,我会找到相同.DLL的许多副本.我的理解是MSVCRT是C运行时库,有点类似于*nix下的glibc/libc.so.

为什么Windows程序必须随身携带他们的C库,而不是仅仅共享系统范围的libc?


更新:感谢Shog9,我开始阅读有关SxS的内容,这进一步让我了解了DLL链接问题(DLL Hell) - http://blogs.msdn.com/b/martynl/archive/2005/10/ 13/480880.aspx是一个有用的介绍问题...

libc msvcrt

21
推荐指数
3
解决办法
7051
查看次数

malloc和calloc是如何以不同的签名结束的?

可能重复:
为什么calloc接受两个参数而malloc只有一个?

很多资源描述了malloc和之间的功能差异calloc,但我不能轻易找到描述不同功能签名背后的历史的资源:

   void *calloc(size_t nmemb, size_t size);
   void *malloc(size_t size);
Run Code Online (Sandbox Code Playgroud)

当然,size前者是每个成员的大小.也许这个想法是可以通过操作系统懒散地完成多页面大小的成员大小的calloc?

(我可以弥补原因以及下一个人 - 没有引用来源没有接受的答案.:-)

c history std libc

20
推荐指数
1
解决办法
2554
查看次数

由于标准C委员会没有标准化gets()的简单替换,它应该是什么?

gets函数首先在C99中弃用,最后在C11中删除.然而,在C库中没有直接替代它.

fgets()不是替代品,因为它不会剥离最终版本'\n',这可能在文件末尾不存在.许多程序员也错了.

有一个单行代码可以删除换行符:buf[strcspn(buf, "\n")] = '\0';但它不重要,通常需要解释.它也可能效率低下.

这会适得其反.许多初学者仍然使用,gets()因为他们的老师是蹩脚的或他们的教程已经过时.

微软提出了gets_s()许多相关的函数,但它并没有默默地截断超长行,这种约束违规的行为并不简单.

BSD和GNU libc都getline在POSIX中标准化,通过realloc... 分配或重新分配缓冲区.

教初学者关于这个混乱的最佳方法是什么?

c glibc libc language-lawyer

19
推荐指数
2
解决办法
329
查看次数

gcc:减少libc所需的版本

我试图在一些旧的32位RedHat发行版上运行一个新编译的二进制文件.
二进制文件在运行libc v2.12的CentOS 32位VM上编译为C(而不是++).

RedHat抱怨libc版本:

error while loading shared libraries: requires glibc 2.5 or later dynamic linker
由于我的程序相当简单,因此很可能不会使用libc中的任何新内容.

有没有办法减少libc版本要求

c linux linker gcc libc

18
推荐指数
2
解决办法
2万
查看次数

"f"代表C标准库函数名称是什么?

什么是f代表在C标准库函数的名称?我注意到很多功能都有f他们的名字,这对我来说并没有多大意义.

例如:fgets,fopen,printf,scanf,sqrtf等.

c naming libc

18
推荐指数
3
解决办法
7445
查看次数

为什么告知"中止"是违法的?

函数GNU libc文档abort包含以下通知:

未来变更警告:建议的联邦审查规定可能禁止我们向您提供有关调用此功能的可能性的信息.我们需要说这不是终止程序的可接受方式.

呃,什么?

我找到了一个七岁的Reddit讨论这个问题.看来该通知是由Richard Stallman在1995年提出的 - 所以它已经存在了一段时间.然而,除了1999年的邮件列表线程声称这是一个笑话,我找不到任何进一步的信息.

那么:这只是一个由rms投入的复活节彩蛋吗?或者它是否严重(虽然可能不再相关)?如果是这样,它指的是什么?

相同功能的Open Group POSIX文档不包含任何类似的内容,也没有我查阅的任何手册页.

c gnu libc code-documentation

17
推荐指数
1
解决办法
1354
查看次数

为什么 __libc_start_main 的地址在 GDB 中始终相同,即使 ASLR 已打开?

Breakpoint 1, 0x00007ffff7de8060 in __libc_start_main () from /usr/lib/libc.so.6
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/firstlove/projects/org-ioslide/example/a.out 

Breakpoint 1, 0x00007ffff7de8060 in __libc_start_main () from /usr/lib/libc.so.6
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/firstlove/projects/org-ioslide/example/a.out 

Breakpoint 1, 0x00007ffff7de8060 in __libc_start_main () from /usr/lib/libc.so.6
(gdb) Quit
(gdb) quit
A debugging session is active.

        Inferior 1 [process …
Run Code Online (Sandbox Code Playgroud)

c linux gdb libc aslr

17
推荐指数
1
解决办法
685
查看次数

关闭FILE指针而不关闭基础文件描述符

通过使用fdopen(),fileno()可以使用现有文件描述符打开流.然而,正确的方法关闭文件,一旦你与流打开它要fclose()FILE指针.如何关闭流,但保留打开的文件描述符?

此行为类似于调用fflush()然后再次fileno()使用FILE指针,除非在关闭时.另一个问题是,如果你fdopen()再次,现在有多个FILE指针,你只能关闭其中一个.

c file stdio stream libc

16
推荐指数
1
解决办法
6057
查看次数

What is causing sprof to complain about "inconsistency detected by ld.so"?

I'm trying to use sprof to profile some software (ossim) where almost all the code is in a shared library. I've generated a profiling file, but when I run sprof, I get the following error:

> sprof /home/eca7215/usr/lib/libossim.so.1 libossim.so.1.profile -p > log
Inconsistency detected by ld.so: dl-open.c: 612: _dl_open: Assertion `_dl_debug_initialize (0, args.nsid)->r_state == RT_CONSISTENT' failed!
Run Code Online (Sandbox Code Playgroud)

The instructions I was following said that I needed libc version at least 2.5-34, I have libc version 2.12.2 (Gentoo, kernel 2.6.36-r5).

I can't …

shared-libraries libc ld dlopen sprof

16
推荐指数
1
解决办法
4413
查看次数

为什么time(time_t*)函数都返回并设置by-ref?

我一直很好奇,为什么time(time_t *)函数都返回一个time_t,并设置传入指针的时间?

返回时间的示例:

time_t myTime = time(NULL);
printf("The time is now %s", ctime(&myTime));
Run Code Online (Sandbox Code Playgroud)

将值设置为指针的示例:

time_t myTime;
time(&myTime);
printf("The time is now %s", ctime(&myTime));
Run Code Online (Sandbox Code Playgroud)

我原本以为通过写入内存而不是返回会有性能提升,但是如果它必须同时执行这两种操作,那是不是只会让它变慢?

c time libc

16
推荐指数
2
解决办法
4064
查看次数

标签 统计

libc ×10

c ×8

linux ×2

aslr ×1

code-documentation ×1

dlopen ×1

file ×1

gcc ×1

gdb ×1

glibc ×1

gnu ×1

history ×1

language-lawyer ×1

ld ×1

linker ×1

msvcrt ×1

naming ×1

shared-libraries ×1

sprof ×1

std ×1

stdio ×1

stream ×1

time ×1