c++ - What does ## (double hash) do in a preprocessor directive? -
#define define_stat(stat) \ struct fthreadsafestaticstat<fstat_##stat> statptr_##stat; the above line take unreal 4, , know ask on over unreal forums, think general c++ question warrants being asked here.
i understand first line defines macro, not versed in preprocessor shenanigans in c++ , i'm lost on there. logic tells me backslash means declaration continues onto next line.
fthreadsafestaticstat looks bit template, there's #'s going on in there , syntax i've never seen before in c++
could tell me means? understand may not have access unreal 4, it's syntax don't understand.
## preprocessor operator concatenation.
so if use
define_stat(foo)
anywhere in code, gets replaced with
struct fthreadsafestaticstat<fstat_foo> statptr_foo;
before code compiled.
here example a blog post of mine explain further.
#include <stdio.h> #define decode(s,t,u,m,p,e,d) m ## s ## u ## t #define begin decode(a,n,i,m,a,t,e) int begin() { printf("stumped?\n"); } this program compile , execute successfully, , produce following output:
stumped? when preprocessor works on code,
begin()replaceddecode(a,n,i,m,a,t,e)()decode(a,n,i,m,a,t,e)()replacedm ## ## ## n()m ## ## ## n()replacedmain()
thus effectively, begin() replaced main().
Comments
Post a Comment