developer

GCC -fPIC option

Question: ❓❓❓ I have read about GCC’s Options for Code Generation Conventions, but could not understand what “Generate position-independent code (PIC)” does. Please give an example to explain me what does it mean. Good Answer: 👌👌👌 Position Independent Code means that the generated machine code is not dependent on being Read more…

By admin, ago
developer

How do I pass a unique_ptr argument to a constructor or a function?

Question: ❓❓❓ I’m new to move semantics in C++11 and I don’t know very well how to handle unique_ptr parameters in constructors or functions. Consider this class referencing itself: #include <memory> class Base { public: typedef unique_ptr<Base> UPtr; Base(){} Base(Base::UPtr n):next(std::move(n)){} virtual ~Base(){} void setNext(Base::UPtr n) { next = std::move(n); Read more…

By admin, ago