Quick question with #define

Will this expand properly?

Inside random header:
1
2
3
4
5
6
7
#pragma once
#include <Version.h>
#define THISVERSION 001

namespace SBV{
    //Codey stuffs here
}


Inside <Versions.h>
1
2
#pragma once
#define SBV SB_THISVERSION 


I want SBV to expand to SB_001 in this case

(PS I put this in the Beginner part because it's a simple question, I don't want people pointing out that I'm using triangle braces for the include because that's all fine with my compiler workspace setup)
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>

#define CAT(x,y) CONCATENATE(x,y) // force macro expansion
#define CONCATENATE(x,y) x##y

#define THIS_VERSION 001

#define SB(V) CAT( SB_, V )

#define SBV SB(THIS_VERSION)

namespace SBV
{
   using std::cout ;
}

int main()
{
    SBV::cout << "hello world\n" ;
    SB_001::cout << "hello again\n" ;
}
Right, thanks for the help.
Such a shame that after that wonderful code you added a using namespace in there XD
Who is XD? And where did this XD add a using namespace directive?
Wow... I have no words!
Topic archived. No new replies allowed.