Note that there are some explanatory texts on larger screens.

plurals
  1. POUse #define macro in C++ to choose implementations from different namespaces
    primarykey
    data
    text
    <p>The multiplatform engine we're developing for our game uses the EASTL to replace the STL, because of memory, performance and portability reasons. The EASTL can be found here:<br/> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html" rel="nofollow">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html</a></p> <p>Because Visual Studio is really good for debugging the STL we're not using the EASTL on Windows while the engine is in development. Also some STL containers as std::queue, std::deque, ... aren't available in the EASTL. Because it doesn't matter we're using the eastl::string on Windows as well, because it's fine for debugging.</p> <p>What we're doing until now is </p> <pre><code>#if (GIN_USE_EASTL) #define ginstl eastl #else #define ginstl std #endif </code></pre> <p>and GIN_USE_EASTL is defined as 0 on windows. <em>The engine is called Ginkgo, thats where the GIN comes from.</em><br/> We're using lists, vectors, ... like this</p> <pre><code>ginstl::list myList; ginstl::vector myVector; </code></pre> <p>which works quite fine. But when we use a string or a queue, because of reasons I explained above, we have to write</p> <pre><code>eastl::string myString; std::queue myQueue; </code></pre> <p>which is the reason why i'm posting here, because this is not optimal! What I want to do is use the ginstl:: macro for everything in the engine, without thinking about what implementation to use. So my approach on the problem was this:</p> <pre><code>#if (GIN_USE_EASTL) #define ginstl::list eastl::list #define ginstl::vector eastl::vector #define ginstl::string eastl::string #define ginstl::queue std::queue #else #define ginstl::list std::list #define ginstl::vector std::vector #define ginstl::string eastl::string #define ginstl::queue std::queue #endif </code></pre> <p>But unfortunalty that's not working, because the :: is not allowed in the #define macro. Is there any way to achieve the same thing (be able to specify which implementation I want to use for a specific datastructure) somehow different? I could go for </p> <pre><code>#define ginstl_list eastl::list </code></pre> <p>but I would prefer the structure from above! Is there a way (except writing a custom pre-processor) around the problem?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload