小编Mat*_*tze的帖子

shared_ptr的缺点

使用c ++ 11中包含的shared_ptr,可以实现半垃圾收集环境.(通货膨胀?)用法是否带来一些缺点?

我可以想象一个类模型,在这里你可以创建一个类,在这个类中你最后输入你的类作为shared_ptr来缩写语法.

/////////////////
//// MyClass ////
/////////////////

#include <memory>

class MyClass {
public:
    Myclass();
};

typedef std::shared_ptr<MyClass> SharedMyClass;

///////////////////////
//// Example Class ////
///////////////////////

class Example {
public:
    Example(): myClassObject(new MyClass()) {}
private:
    SharedMyClass myClassObject;
};
Run Code Online (Sandbox Code Playgroud)

c++ smart-pointers shared-ptr c++11

8
推荐指数
1
解决办法
3202
查看次数

Eclipse CDT Indexer无法完全识别c ++ 11

首先,我知道-std = c ++ 11标志以启用c ++ 11支持以及放置它的位置.我已经追加-std=c++11Project -> Properties -> C/C++ Build -> Settings -> Tool Settings -> GCC C++ Compiler -> Miscellaneous -> Other Flags和编译只是正常工作.但是,如果我想使用的索引不相处,例如emplace功能std::map(C++ 11),也不会找到布设功能.

#include <map>

int main() {
    std::map<int, int> data;
    data.emplace(5,5);
Run Code Online (Sandbox Code Playgroud)

我还查看了这些相关问题:

更新:现在我已经玩过它甚至无法识别std :: map类型,虽然编译精细和eclipse找到所有标题...

  • 编译器Mingw64 GCC 5.2.0
  • Eclipse Mars 4.5
  • CDT 8.7

c++ eclipse eclipse-cdt c++11

4
推荐指数
1
解决办法
4533
查看次数

SDL不在本机环境中编译

我正在尝试用SDL编译这段代码

#include <SDL.h>
int main(int argc, char * argv[]){
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

文件本身编译得很好

g++ -c main.cpp -ISDL/include
Run Code Online (Sandbox Code Playgroud)

但是使用g ++在cygwin中使用以下命令进行编译

g++ -o test main.o  -lSDL2 -lSDL2main -L SDL/lib/x64
Run Code Online (Sandbox Code Playgroud)

产生这个巨大的错误......在我看来,这似乎是SDL本身的问题......

$ g++ -o test main.o  -lSDL2 -lSDL2main -L SDL/lib/x64
Warning: corrupt .drectve at end of def file
SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[main]+0xe): undefined reference to `SDL_SetMainReady'
SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[main]+0xe): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SDL_SetMainReady'
SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[WinMain]+0x29): undefined reference to `SDL_wcslen'
SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[WinMain]+0x29): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SDL_wcslen'
SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[WinMain]+0x46): undefined reference to `SDL_iconv_string' …
Run Code Online (Sandbox Code Playgroud)

c++ cygwin sdl g++ sdl-2

0
推荐指数
1
解决办法
2023
查看次数

标签 统计

c++ ×3

c++11 ×2

cygwin ×1

eclipse ×1

eclipse-cdt ×1

g++ ×1

sdl ×1

sdl-2 ×1

shared-ptr ×1

smart-pointers ×1