From: Lars M. <lar...@te...> - 2015-03-18 19:32:58
|
Hello, today i stumbled upon the following problem: imagine you'r defining a struct via constants and you want to use a c union-like layout, for example: %define TYPE_ARRAY_OFFSET_DATA_TYPE 0x0000 %define TYPE_ARRAY_OFFSET_LENGTH 0x0004 %define TYPE_ARRAY_SIZE 0x0008 %define TYPE_STRUCT_ .... [and so on] %define TYPE_OFFSET_INDEX 0x0000 %define TYPE_OFFSET_LAYOUT 0x0004 ; union of type_array, type_struct %define TYPE_SIZE max TYPE_ARRAY_SIZE, TYPE_STRUCT_SIZE %define TYPE_LAYOUT_ARRAY_DATA_TYPE ( TYPE_OFFSET_LAYOUT + TYPE_ARRAY_OFFSET_DATA_TYPE ) %define TYPE_LAYOUT_ARRAY_LENGTH ( TYPE_OFFSET_LAYOUT + TYPE_ARRAY_OFFSET_LENGTH ) thus you have a full type_array or type_struct structure at TYPE_OFFSET_LAYOUT. Now I need the max-macro to get the maximum size of both structures. I could calc this value manually, but this is not the sense of a preprocessor. I tried to implement it via macros but this won't work. Any ideas? Maybe add the min, max operator to the preprocessor? Best wishes! |