#Variadic arguments issue. LogErr( "This used to work %s", func_that_returns_ptr_to_string(var) );

6 messages · Page 1 of 1 (latest)

night yacht
#

I have Log functions. Macro'ed up a bit to be confusing. I recently had to rewrite them and while they got cleaner, the example above no longer works.

I'd like it to work again! Not sure how to get there. It seems to be attempting to print the pointer address of the function, instead of performing the function and using the result pointer. So the log entry looks something like "This used to work 6100333B"

//LogXXX is a maco
#define LogInfo(...)                             \
log_expansion(LOG_OPTIONS, LOG_LEVEL_INFO, __VA_ARGS__)

// Which expands to a temporary macro expansion to add constant data
#define log_expansion(LOG_OPTIONS,               \
                      MESSAGE_LOG_LEVEL,         \
                      ...)                       \
                log_formatter(LOG_OPTIONS,       \
                              LIBRARY_LOG_LEVEL, \
                              LIBRARY_LOG_NAME,  \
                              MESSAGE_LOG_LEVEL, \
                              NULL,              \
                              0,                 \
                              __VA_ARGS__)       

// log_formatter will get the data to a queue that is then later printed out. Think snprintf and printf.

Also not working LogInfo("Feature is: %s", FEATURE_ON_BOOL ? "ON" : "OFF"); For the same cause I think.

I don't know what I need. Could be as easy as a well placed () or a do while(0). I don't see it yet. Thoughts?

daring bearBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

terse burrow
#

Could you provide an error log?

daring bearBOT
#

This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.

night yacht
#

!solved

daring bearBOT
#

Thank you and let us know if you have any more questions!