-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #788, Simplified CFE_EVS_SendEvent macros #867
Fix #788, Simplified CFE_EVS_SendEvent macros #867
Conversation
Should I, as part of this PR, change a bunch of cFE code to use these simplified macro calls? |
I like keeping things separate. So at the very least do it in separate commits. Another option is to provide a sample implementation or documentation with this PR. And, once the approach is "approved" by the CCB open a PR to update the cFE code. |
This could be done with an inline function instead of a macro if a version of |
Suggestion for less duplicate code:
instead:
... and so on |
@klystron78 - copy, a helper macro for the helper macros. I'm fine with either approach. |
Looks like double underscore bolds in the comments. There's probably a way to do a code block or something like that. |
@Klystron single back quote (just learned also known as birk, blugle, or grave)
|
I'm confused what the benefit is of an inline (which, of course, isn't always inline) over a macro. Can you describe/prototype? |
I like, I'll change, thanks! |
General advice these days seems to be to prefer inline functions over function-like macros. For example, see SEI CERT Recommendation PRE00-C. I admit, for this sort of trivial wrapper, the benefit is probably small and probably outweighed by the additional lines of code. It would look something like the following (using a hypothetical static inline int32 CFE_EVS_SendDbg(uint16 EventID, const char *Spec, ...)
{
va_list ap;
va_start(ap, Spec);
int32 res = CFE_EVS_VSendEvent(EventID, CFE_EVS_EventType_DEBUG, Spec, ap);
va_end(ap);
return res;
} |
I'm generally a fan of inline functions rather than macros because they are more type-safe, and they offer more predictable/defined behavior as to when things are evaluated and when side effects occur, such as the classic example of a macro that evaluates its arguments more than once. Admittedly they aren't quite as useful in C as they are in C++, where you have templates. So in C we need a explicitly-defined inline function for every type variant, whereas a macro or C++ template can be evaluated at compile-time for any type. It is true they are not always actually inlined - it's a suggestion to the compiler, but depends on compiler capabilities, settings, etc as to whether it accepts that suggestion. But I'm not sure if any compiler can inline something that uses |
@CDKnightNASA is this ready to merge? |
yes please |
@astrogeco - what's the status on this one? |
Whoops, looks like this never made it to a CCB since it hasn't been "github reviewed". Tagging it for next week Edit-1: Unless we did review it and I forgot to comment on it :( I'm looking through the old agendas right now |
@skliper or we could fast-track it |
CCB 2020-11-04 APPROVED @CDKnightNASA can you rebase/squash the commits? |
* Add nasa/cFE#984 * Add nasa/cFE#980 * Add nasa/cFE#867 * Add nasa/osal#638 and update cfe due to rebase * Add nasa/cFE#987 * Add nasa/to_lab#64 and nasa/sample_app#104 * Add nasa/osal#643 * Add nasa/cFE#1000 * Add nasa/ci_lab#58 * Add doxygen fixes for nasa/osal#643 * Add nasa/cFE#1013 * Add nasa/cFE#1011 * Add nasa/ci_lab#61 * Add nasa/sample_app#109 * Bump versions and point to submodules main Co-authored-by: Joseph Hickey <[email protected]>
Closes #788
Describe the contribution
Macros for more compact calls to CFE_EVS_SendEvent, making the type be part of the fn name.
Contributor Info - All information REQUIRED for consideration of pull request
[email protected]