-
yuripv
what exactly cstyle isn't happy about here:
pastebin.com/HC8Sr30G? "t.h: 1: missing space before left brace"
-
yuripv
adding whitespace before brace makes it say "whitespace after left paren"
-
jclulow
yuripv: I think you want a do {} while (0) guard there?
-
jclulow
-
jclulow
without the _NOTE(CONSTCOND) obviously because we don't note.h anymore
-
yuripv
the macro is used then as "val = MACRO(arg);" and that fails with "expected expression before 'do'"
-
yuripv
not my code, and it builds and works fine as it is, it's just cstyle that isn't happy
-
jclulow
macros that return things feel somewhat unsavoury
-
jclulow
unless they're just expressions
-
jclulow
inline function perhaps?
-
jclulow
If it has to be a macro I don't know what the parens around the braces buy you
-
jclulow
so I would try removing them?
-
yuripv
expected expression before '{' token
-
jclulow
can you maybe show me more of the code
-
yuripv
so inline functions could be an answer here
-
jclulow
I think inline functions are probably in general better than macros for a variety of reasons though yeah
-
jclulow
(more contained, more type safe, less accidental double-evaluation of arguments, etc)
-
yuripv
-
yuripv
as an example
-
jclulow
ah
-
jclulow
We're definitely into a corner of C I am not comfortable in haha
-
jclulow
that really doesn't seem like it could possibly be an expression
-
jclulow
also.. __typeof yeesh
-
yuripv
and __typeof for type of return value would not allow for inline function?
-
jclulow
I guess yeah
-
jclulow
I suppose you can always /*CSTYLED*/ it!
-
jclulow
also, this must surely be in whacky third party code?
-
jclulow
-
jclulow
if we're planning to update it in future without restyling it for example
-
jclulow
is it from some SNMP thing?
-
yuripv
yes, 3d party code that i'm just trying to build and look a bit better
-
yuripv
yep
-
yuripv
experimenting with begemot snmp implementation instead of unwieldy net-snmp
-
jclulow
if it's 3rd party it would not be the end of the world for it to be cstyle exempt on some level, I suspect. Probably someone else should weigh in to tell me I'm not crazy
-
yuripv
thanks Joshua
-
jclulow
you're welcome!
-
jclulow
hope the experiment goes w{ll
-
jclulow
*well
-
igork
tsoome ping
-
richlowe
I think gcc finds that to be an expression
-
richlowe
I'm not sure if that's an extension
-
richlowe
isn't that the same kind of weird trick we pull for strdupa (in spirit, if not in fact?)
-
richlowe
yeah, we wrap it in __extension__() and damn the indentation
-
richlowe
see string.h
-
richlowe
I'd prefer /*CSTYLED*/ to just ignoring taste
-
richlowe
it's meant to make your code "fit in", not to make your code fucking ugly because a perl script says so
-
richlowe
if that helps guide you :)
-
alanc
yes, ({...}) are gcc "statement expressions", which I doubt cstyle ever knew about:
gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
-
alanc
they're proposed for a version of the C standard after C23, but for now I think are just a gcc extension that some other compilers (including Studio 12.6 I believe) now also support