Home > front end >  How to use __attribute_format_arg__ on a function not returning a char* but a object around it wrapp
How to use __attribute_format_arg__ on a function not returning a char* but a object around it wrapp

Time:10-15

I have a function that looks kind of like this:

Exception* make_exception(Exception* caused_by, size_t caused_at, const char* format, ...) __attribute_format_arg__(3);

The Exception type is just a struct containing the result of the function. I get the following error:

error: function does not return string type

Is there any way to fix this?

CodePudding user response:

You want to use:

#ifdef __GNUC__
__attribute__((__format__(__printf__, 3, 4)))
#endif
Exception* make_exception(Exception* caused_by, size_t caused_at, const char* format, ...);

See https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes .

  •  Tags:  
  • c
  • Related