[Z88dk-users] Default parameter values in header files?

Bridge to the z88dk-users mailing list
Post Reply
obiwanjacobi
Member
Posts: 67
Joined: Tue Dec 22, 2015 7:39 am

[Z88dk-users] Default parameter values in header files?

Post by obiwanjacobi »

Looks like this is not supported...

Code: Select all

void some_function(int some_param = 0);
Or am I doing something (else) wrong?

Was hoping to make some debug macros with __FILE__ and __LINE__ ...



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

Looks like this is not supported...

Code: Select all

void some_function(int some_param = 0);
Default parameters are a C++ feature.

I've seen some people use macros to simulate default parameters.

Code: Select all

#define some_function_0()     some_function_impl(100,200)
#define some_function_1(a)    some_function_impl(a,200)
#define some_function_2(a,b)  some_function_impl(a,b)

extern void some_function_impl(int a, int b);

void main(void)
{
some_function_0();
some_function_1(500);
some_function_2(0,1);
}
The names of the macros are differentiated by the number of parameters they take.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
obiwanjacobi
Member
Posts: 67
Joined: Tue Dec 22, 2015 7:39 am

Post by obiwanjacobi »

Looks like this is not supported...
Default parameters are a C++ feature.
Gets me every time... :D

Right, I'll see what I can do with some macro magic. Thanks.
(Happy New Year! - almost)



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Post Reply