jjzjj

c++ - g++ 选项显示哪些类是从模板创建的

是否有一些g++选项显示哪些类是从模板创建的?例如原始源代码中有模板定义:templatestructSomeStruct{Tvariable;};SomeStructinstance;我希望看到SomeStruct的实现。 最佳答案 您可以使用-fdump-class-hierarchy标志获取该信息。它会列出比您要求的更多的内容,但如果搜索以Class开头的行,您会找到您要查找的内容。编辑:这是包含iostream的程序的一些输出。可以看到有char和wchar_t的实例化:Classstd::basic_ostream>Cla

c++ - 当协程切换线程时,如何强制 Linux 上的 g++ 更新线程指针(用于 TLS)?

我在C++(编译器g++,在ARM上)中使用协程的自定义实现。协程可能会通过调用move_to_thread函数(或其他方式,但这将让我说明我的观点)从一个线程迁移到另一个线程。我过于简单化了,但它有点像这样:__threadintx=0;voidf(){x=5;//dosomemoreworkoncurrentthread(thread1,say)move_to_thread(2);//domorework,nowonthread2inty=x;//withoptimization,I'mgettingthewrongx}我遇到的问题是调用move_to_thread之前和之后完成的

c++ - 为什么 "cc1plus: warning: unrecognized command line option"选项的 "no-"仅在出现另一个警告时由 g++ 标记?

>catwarning.cpp#pragmafoobar>catno_warning.cpp#pragmamessage"foobar">g++-Wall-Wno-foobar-cwarning.cppwarning.cpp:1:0:warning:ignoring#pragmafoobar[-Wunknown-pragmas]cc1plus:warning:unrecognizedcommandlineoption"-Wno-foobar"[enabledbydefault]>g++-Wall-Wno-foobar-cno_warning.cppno_warning.cpp:1:17

c++ - g++ 错误 : specialization after instantiation (template class as friend)

考虑以下C++代码:templateclassSingleton{};classConcreteSingleton:publicSingleton{templatefriendclassSingleton;};intmain(){}Singleton应该是ConcreteSingleton的friend:它适用于Microsoft的可视化C++编译器。但是,我不能用g++4.8.4编译它。错误是:error:specializationof‘Singleton’afterinstantiationtemplatefriendclassSingleton;有什么办法可以解决吗?

c++ - -Wundef 不会被 g++ 中的 pragma 忽略

给定以下代码:#ifMACRO_WITHOUT_A_VALUEintvar;#endifintmain(){}编译时,g++-std=c++1z-Wundef-omainmain.cpp,它会产生以下警告:main.cpp:1:5:warning:"MACRO_WITHOUT_A_VALUE"isnotdefined[-Wundef]#ifMACRO_WITHOUT_A_VALUE^我想保持启用警告标志,但抑制这个特定实例。我应用以下内容:#ifdef__GNUC__#pragmaGCCdiagnosticignored"-Wundef"#pragmaGCCdiagnosticpush

c++ - 带有 g++ 5.4.0 的 asan 无法在 travis CI 上运行

直到最近,我使用地址清理器在travis上使用g++5进行的构建都通过了——在过去的一周中它们崩溃了。我看到g++的版本从(Ubuntu5.2.1-23ubuntu1~12.04)5.2.120151031升级到(Ubuntu5.4.0-3ubuntu1~12.04)5.4。020160603(从${CXX}--version行看)错误来自链接器-/usr/bin/ld:unrecognizedoption'--push-state'最后一个工作版本-here当前损坏的构建-here知道这是否是一个已知问题吗?是不是到处都被举报了?有解决方法吗?here是我在github上的存储库——

c++ - 使用 g++ 和 clang++ 调用 Integral 模板成员函数时出错

这个问题在这里已经有了答案:WhereandwhydoIhavetoputthe"template"and"typename"keywords?(8个答案)关闭7年前。我目前陷入编译错误,我无法真正识别...这是一个最小的工作示例:#includetemplateclassa_type{public:templatedoublesegment(){return42;}};templatedoublefunc(){a_typea;returna.segment();}intmain(intargc,char*argv[]){std::cout()来自GCC的错误信息如下:g++main.

c++ - G.711 C++ 实现

你能建议用C/C++实现G.711音频编解码器吗?我将在专有软件中使用它。 最佳答案 我使用实现here,简单快捷。 关于c++-G.711C++实现,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/6519369/

c++ - Comeau vs g++ [又一个错误]

考虑以下测试1代码structA{private:classface;friendclassface;};structA::face{};templatestructC:publicA::face{};intmain(){Cx;}这段代码格式正确吗?我在g++和comeau下测试了它。g++可以很好地编译它,而comeau会给出以下错误消息(我认为这是正确的)"ComeauTest.c",line12:error:class"A::face"(declaredatline9)isinaccessiblestructC:publicA::face^detectedduringinstan

c++ - 为 g++ 永久添加包含路径和共享库

我尝试在终端中用g++编译.cpp文件:g++-omainmain.cpp\-I/usr/include/glib-2.0\-I/usr/include/json-glib-1.0\-I/usr/lib/x86_64-linux-gnu/glib-2.0/include/\-L/usr/lib/x86_64-linux-gnu-ljson-glib-1.0-lglib-2.0而且它有效。但我想添加这些.so库并永久包含g++文件,这样我就不需要每次都输入这些文件。而且我还想让它适用于其他应用程序。我正在使用ubuntu。谁能帮帮我?非常感谢您。 最佳答案