我写了一个这样的测试程序:
#include <sys/socket.h>
int main( void ) {
int sock = socket(AF_INET, SOCK_DGRAM, 0);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
并试图编译它:
$ /tool/sunstudio/bin/cc test.c
Undefined first referenced
symbol in file
socket test.o
ld: fatal: Symbol referencing errors. No output written to a.out
Run Code Online (Sandbox Code Playgroud)
输出是"未引用符号套接字".
请给我指示,以便我可以解决这个问题.
我在SunOS 5.11(Solaris 11.3)上使用Sun Studio 12.3.我需要看到Sun Studio定义的宏来修复在套件下获取的错误报告.这与Solaris和预处理器宏类似,但引用的问题使用GCC及其预处理器; 而不是Sun Studio的预处理器.
我跑了,CC -flags但我没有看到类似于GCC cpp -dM或者的选项g++ -dM -E - </dev/null.CC确实有-E,但它相当贫血,不打印任何预处理器定义:
$ echo $CXX
/opt/solarisstudio12.3/bin/CC
$ $CXX -E /dev/null
#1 "/dev/null"
Run Code Online (Sandbox Code Playgroud)
使用真实的测试文件会产生类似的结果 - 缺少预处理器宏:
$ $CXX -E test.cxx | grep __cplusplus
$
Run Code Online (Sandbox Code Playgroud)
我还在2.5.3预定义名称的Sun Studio手册中找到了对预处理器宏的讨论.表A-2是可以的,但它也大多贫血.它缺少基础知识__cplusplus,而其缺少的其他定义如_RWSTD_NO_CLASS_PARTIAL_SPEC.
如何在Sun Studio下打印预处理器宏?
$ /opt/solarisstudio12.3/bin/CC -flags
______________________________________________________________________________
Items within [ ] are optional. Items within < > are variable parameters.
Bar | indicates choice of …Run Code Online (Sandbox Code Playgroud) 我在使用Sun Studio编译器的Solaris上遇到问题,这很可能是由于使用了奇怪的STL实现(libCstd),请参阅http://developers.sun.com/solaris/articles/cmp_stlport_libCstd.html.考虑一下:
std::vector<C*> v;
// .. populate the vector
std::sort(v.begin(), v.end());
Run Code Online (Sandbox Code Playgroud)
C某个班级在哪里.这会产生以下编译器错误消息:
"/opt/sunstudio12.1/prod/include/CC/Cstd/./algorithm", line 725: Error: The operand "*first" cannot be assigned to.
"/opt/sunstudio12.1/prod/include/CC/Cstd/./algorithm.cc", line 985: Where: While instantiating "std::__linear_insert<C*const*, C*>(C*const*, C*const*, C**)".
"/opt/sunstudio12.1/prod/include/CC/Cstd/./algorithm.cc", line 985: Where: Instantiated from std::__insertion_sort<C*const*>(C*const*, C*const*).
"/opt/sunstudio12.1/prod/include/CC/Cstd/./algorithm", line 811: Where: Instantiated from non-template code.
Run Code Online (Sandbox Code Playgroud)
有人知道如何规避这个问题吗?当然,实际上我想使用std::sort自定义比较仿函数,但即使是这个简单的版本也行不通.
我正在开发 Solaris 11,已打完补丁。我试图通过在 ISA 下转储预处理器宏来确定编译器是否支持 ISA。
Make 由于Missing Separator. Missing Separator当与 GNU make 的shell 函数一起使用时,我无法找到有关错误的信息。
这是简化的情况。没有空格,因此它不是像“ Make error:缺少分隔符和朋友”中那样的空格/制表符问题。
$ cat -n GNUmakefile-test
1 EGREP ?= egrep
2 SUN_COMPILER := $(shell $(CXX) -V 2>&1 | $(EGREP) -i -c "CC: (Sun|Studio)")
3
4 # Begin SunCC
5 ifeq ($(SUN_COMPILER),1)
6 $(info "Sun compiler")
7 $(shell $(CXX) $(CXXFLAGS) -E -xarch=ssse3 -xdumpmacros /dev/null 2>/dev/null)
8 ifeq ($(.SHELLSTATUS),0)
9 $(info "SSSE3")
10 SSSE3_FLAG = -xarch=ssse3 -D__SSSE3__=1
11 endif
12 …Run Code Online (Sandbox Code Playgroud) 请考虑以下代码:
extern "C" {
#include <lib.h>
}
#include <iostream>
int main() {
unsigned char a='a';
unsigned char b=some_struct_in_libh->unsignedchar;
cout << a << " " << b << endl; //Prints only a
printf("%u\n",b); //Prints b
cout << static_cast<int>(b) << endl; //Also prints b
return 0;
}
Run Code Online (Sandbox Code Playgroud)
为什么它会像这样?