C Macro Conversion

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by dmoc.

Hiya, any advice on the following appreciated: I need to convert several C macro's used to implement platform specific variable indexing based on variable type, or more specifically the size of variable types. Sorry if this is confusing but if you don't understand then you probably cannot help...

#define VARARG_ROUND_UP(n,unit) ((((n) + (unit) - 1) / (unit)) * (unit))

#define VARARG_START(_AP,_LASTNAMEDARG) ((_AP) = (char *) &(_LASTNAMEDARG) + VARARG_ROUND_UP(SizeOf(_LASTNAMEDARG),SizeOf(int)))

I started converting and then realised that PB does not provide any functions to determine var type or "SizeOf()" (except structures of course). At the moment I am only proof testing on W32 platform but as I am only doing this while waiting for the next Linux release of PB, I would like to keep the converted macros platform-independent. So...
1) any suggestions (at all) for W32 specific conversion?
2) any suggestions for platform independent conversion?

TIA - DOC

PS: I am soooooooooo glad this forums are back up!
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

You can use a procedure for the 1st macro (which is of course slower, but which will work). The 2nd one is a bit more tricky...

Fred - AlphaSND
Post Reply