Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 02 Mar 2006
Offline Last Active Today, 12:20 PM

Posts I've Made

In Topic: Preprocessor query

14 September 2014 - 09:28 AM

Got it working a treat, thanks.

#define _lock_flag_helper_final(a, b) flag_lock_object _flag_lock_object_##b(a)
#define _lock_flag_helper(a, b) _lock_flag_helper_final(a, b)
#define lock_flag(a) _lock_flag_helper(a, __COUNTER__)

In Topic: Preprocessor query

14 September 2014 - 06:36 AM

That's an infamous gotcha of trying to concat macros' contents instead of their names, you just need 2x indirection,

#define test_helper(a, b) int a ## b#define test(a, b) test_helper(a, b)void f(){    test(name, __LINE__);}
See for full technicalities: http://stackoverflow.com/questions/1597007/creating-c-macro-with-and-line-token-concatenation-with-positioning-macr
Thank you. I think I tried that after some googling last night but I will try again based on yours and post the full if it fails again.

[edit] Ah, I think I can see something I didn't do in the link you posted. Cheers, much appreciated.

In Topic: Preprocessor query

14 September 2014 - 06:35 AM

Won't this turn __COUNTER__(a) into a string instead of calling macro and turning result into a string?

There's some command line parameter to output preprocessed file, that way you can see result you're getting instead of playing guessing game.

No. Think you are thinking of the # (stringize) operator rather than ## (concatenation) operator.

And I'm not guessing. I can see what is being produced in the errors I get if I create more than one in a scope. But using the flag to inspect is a good idea. Thanks.

In Topic: GOTO, why are you adverse to using it

11 September 2014 - 02:09 PM

Why don't people quoting these multiple resource acquisition examples just do this:

bool do_acquire(Res &r1, Res &r2, Res &r3)
    if(!acquireRes(r1)) return false;
    if(!acquireRes(r2)) return false;
    if(!acquireRes(r3)) return false;

    return true;

void acquire()
    Res r1, r2, r3;

    if(!do_acquire(r1, r2, r3))
I'm deliberately simplifying and avoiding the use of RAII to make it as close to the examples posted. What possible advantage does goto give you over this equivalent approach?

In Topic: Other Uses for Graphic Libraries

09 September 2014 - 01:47 PM

Also: accept early it is highly unlikely anyone will use your tools. Market is saturated with excellent free versions of everything written by big teams of very clever people.

Motivation based on one day having a significant user base in this area is fraught with peril.

That said, I wrote/am writing my own 3D modeller that I use and it was a joy to write and is great to have total control of my workflow.