有没有好的在线教程来编写可移植的 C 语言?
我正在使用一些可移植 C 语言开发的工具,这些工具可在 Windows Visual Studio 2008 中运行,而在 Ubuntu Linux 中的 gcc 则基于 #ifdef _WIN32
,但添加对 Solaris 的支持似乎更棘手,特别是如果我想要的话支持cc
以及gcc
。
举个例子,我有一些代码将 sprintf
放入已分配的内存缓冲区中,该缓冲区在 Linux/gcc 和 _vscprintf
/vsprintf 上使用
在 Windows/MSVC 上。两者在 Solaris 上都不可用,我可以使用 vasprintf
vsnprintf
,但我不知道要向我的 #ifdef
添加什么内容,也不知道是否应该转向其他内容。
希望我不必再用 cygwin、mingw 进行配置。
I have some tools I'm working on in portable C that works in Windows Visual Studio 2008 and gcc in Ubuntu Linux based on #ifdef _WIN32
but adding support for Solaris seems to be trickier, especially if I want to support cc
as well as gcc
.
For one example I have some code which sprintf
s into an allocated memory buffer which uses vasprintf
on Linux/gcc and _vscprintf
/vsprintf
on Windows/MSVC. Neither are available on Solaris where I could use vsnprintf
but I have no idea what to add to my #ifdef
s or whether I should move to something else.
Hopefully I don't have to move to configure with cygwin, mingw.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
autoconf(1)
手册有一个 可移植 C 编程部分。The
autoconf(1)
manual has a section on portable C programming.