如何编译c++而不包括cstdio和其他c标准库

how to compile c++ and not include cstdio and other c standard libraries

我是一名 C 程序员,只有很少的 C++ 专业知识。我一直在尝试从 here and here 下载并安装软件包。我 运行 configuremake 以及 dsr-pdb,我得到了转换或错误,例如

../include/dsrpdb/Point.h:69:14: error: 'assert' was not declared in this scope
assert(i < 3);

对于 synaps 我得到

if g++ -DHAVE_CONFIG_H -I. -I. -I../include/synaps   -I/usr/include -I../include -O3 -g -O2 -MT Variables.o -MD -MP -MF ".deps/Variables.Tpo" -c -o Variables.o `test -f '../mpol/src/Variables.cpp' || echo './'`../mpol/src/Variables.cpp; \
    then mv -f ".deps/Variables.Tpo" ".deps/Variables.Po"; else rm -f ".deps/Variables.Tpo"; exit 1; fi
../mpol/src/Variables.cpp: In member function ‘std::string SYNAPS::Variables::operator[](int)’:
../mpol/src/Variables.cpp:16:25: error: ‘sprintf’ was not declared in this scope 
sprintf(str,"%d",i);

这些是错误,因为它们的源文件中没有 #include <cassert>#include <cstdio>。我发现两个不同的开发人员这样做很奇怪。这让我想知道是否有一个编译器选项可以自动使用适当的 c-header 和库文件,或者他们是在 IDE 中开发的,可以让他们摆脱它?或者也许是 autoconf 或 make 做一些上游的事情?

gcc 有一个 -include 选项,可以让您从命令行强制包含头文件。参见 https://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_2.html#SEC11