Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Pollthread: Fix multiline macro definitions #451

Merged
merged 1 commit into from
May 15, 2018

Conversation

t-b
Copy link
Collaborator

@t-b t-b commented May 9, 2018

GCC 8.1.0 outputs

/home/firma/devel/cppTango/cppapi/server/pollthread.cpp:1269:11: warning: macro expands to multiple statements [-Wmultistatement-macros]
T_ADD(ite_next->wake_up_date,min_delta - diff);
^~~~~~~~
/home/firma/devel/cppTango/cppapi/server/pollthread.h:196:2: note: in definition of macro ‘T_ADD’
A.tv_usec = A.tv_usec + B;
^
/home/firma/devel/cppTango/cppapi/server/pollthread.cpp:1268:4: note: some parts of macro expansion are not guarded by this ‘if’ clause
if (diff < min_delta)
^~

which is correct as T_ADD is a multiline macro and thus should be
enclosed in do { } while(0) as described in https://gcc.gnu.org/onlinedocs/cpp/Swallowing-the-Semicolon.html#Swallowing-the-Semicolon.

GCC 8.1.0 outputs

/home/firma/devel/cppTango/cppapi/server/pollthread.cpp:1269:11: warning: macro expands to multiple statements [-Wmultistatement-macros]
     T_ADD(ite_next->wake_up_date,min_delta - diff);
           ^~~~~~~~
/home/firma/devel/cppTango/cppapi/server/pollthread.h:196:2: note: in definition of macro ‘T_ADD’
  A.tv_usec = A.tv_usec + B; \
  ^
/home/firma/devel/cppTango/cppapi/server/pollthread.cpp:1268:4: note: some parts of macro expansion are not guarded by this ‘if’ clause
    if (diff < min_delta)
    ^~

which is correct as T_ADD is a multiline macro and thus should be
enclosed in do { } while(0) as described in https://gcc.gnu.org/onlinedocs/cpp/Swallowing-the-Semicolon.html#Swallowing-the-Semicolon.
Copy link
Member

@bourtemb bourtemb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @t-b for this PR.

@bourtemb bourtemb merged commit 756aa52 into tango-controls:tango-9-lts May 15, 2018
bourtemb added a commit that referenced this pull request May 15, 2018
bourtemb pushed a commit to bourtemb/cppTango that referenced this pull request Jul 17, 2018
GCC 8.1.0 outputs

/home/firma/devel/cppTango/cppapi/server/pollthread.cpp:1269:11: warning: macro expands to multiple statements [-Wmultistatement-macros]
     T_ADD(ite_next->wake_up_date,min_delta - diff);
           ^~~~~~~~
/home/firma/devel/cppTango/cppapi/server/pollthread.h:196:2: note: in definition of macro ‘T_ADD’
  A.tv_usec = A.tv_usec + B; \
  ^
/home/firma/devel/cppTango/cppapi/server/pollthread.cpp:1268:4: note: some parts of macro expansion are not guarded by this ‘if’ clause
    if (diff < min_delta)
    ^~

which is correct as T_ADD is a multiline macro and thus should be
enclosed in do { } while(0) as described in https://gcc.gnu.org/onlinedocs/cpp/Swallowing-the-Semicolon.html#Swallowing-the-Semicolon.
bourtemb added a commit to bourtemb/cppTango that referenced this pull request Jul 17, 2018
@t-b t-b deleted the bugfix/pollthread-error branch October 23, 2019 13:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants