Category : macros

In visual studio I’ve set configuration type as .dll instead of .exe and because of that sometimes I need to use __declspec(dllexport) or __declspec(dllimport) . So I’ve created macros for them inside header file called "Core" #pragma once #ifdef B5_PLATFORM_WINDOWS #ifdef B5_BUILD_DLL #define B5_API __declspec(dllexport) #else #define B5_API __declspec(dllimport) #endif // B5_BUILD_DLL #else #error Bos5 ..

Read more

I develop a legacy project which uses macros to wrap functions and perform some additional actions. Each function has a corresponding macro. Here is a simplified example which shows how a macro call the function (I removed other actions performed by PROXY macro for simplicity): #define PROXY(name, args) prefix##name(args) void prefixFunName(int x){} #define prefixFunName(…) PROXY(FunName, ..

Read more

I have a macro defined like this: #define Test_Flag = 1 Later I want to define an element within a struct which is named the same: struct adress{ char name; char Test_Flag; }; struct Adress {0,1} I already tried the following: struct adress{ char name; char Test_##Flag; }; Is there a way to get this ..

Read more

This may be a stupid question. If I want to use the std::vector implementation with the _GLIBCXX_INLINE_VERSION defined as 1, what should I do? #define _GLIBCXX_INLINE_VERSION 1 #include <vector> static_assert(_GLIBCXX_INLINE_VERSION); // error: static assertion failed I tried to pass the -D_GLIBCXX_INLINE_VERSION flag to gcc, but it did not work, since <vector> contains c++config.h, and _GLIBCXX_INLINE_VERSION ..

Read more

I have two macros: #define TEST_EQUALS_INTEGER(observed,expected) test_check_equals_integer(observed,expected,__FILE__,__LINE__, "%s,%s",#observed,#expected) #define TEST_EQUALS_DECIMAL(observed,expected) test_check_equals_decimal(observed,expected,__FILE__,__LINE__, "%s,%s",#observed,#expected) They are calling these functions test_check_equals_integer(int obs, int exp, const char* file, int line, const char* fmt, …) test_check_equals_decimal(float obs, float exp, const char* file, int line, const char* fmt, …) When i try to access the line argument in test_check_equals_integer I see ..

Read more