Skip to content
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 #1166, recognize ifdef __cplusplus #1169

Conversation

jphickey
Copy link
Contributor

Describe the contribution
Add feature to generate_stubs.pl input phase to recognize and skip over #ifdef __cplusplus blocks. This makes it so it
can be used on C headers which are C++-enabled too.

The logic should be fairly easy to extend to other #if conditionals as needed.

Fixes #1166

Testing performed
Generate stubs for a C header that has C++-aware extern wrappers in it.

Expected behavior changes
Stubs for prototypes inside C++ extern "C" block are generated successfully.

System(s) tested on
Ubuntu

Additional context
Tempting to attempt to use gcc proprocessor here (-E) to get full evaluation of all preprocessor logic, but this would depend on the target headers and may introduce more problems than it solves. So in the interim this just adds a local check that specifically looks for #ifdef __cplusplus and filters out everything inside this block.

Contributor Info - All information REQUIRED for consideration of pull request
Joseph Hickey, Vantage Systems, Inc.

@jphickey jphickey added the CCB:Ready Pull request is ready for discussion at the Configuration Control Board (CCB) label Sep 28, 2021
Add feature to generate_stubs.pl input phase to recognize and
skip over `#ifdef __cplusplus` blocks.  This makes it so it
can be used on C headers which are C++-enabled too.
@jphickey jphickey force-pushed the fix-1166-stubgen-ifdef-cplusplus branch from 78f59db to f2fbc90 Compare September 28, 2021 13:41
@jphickey
Copy link
Contributor Author

Note I did not test this with anything nested deeply/complexly - for example it currently does not handle #elif blocks.

@astrogeco astrogeco removed the CCB:Ready Pull request is ready for discussion at the Configuration Control Board (CCB) label Sep 29, 2021
@astrogeco
Copy link
Contributor

@astrogeco astrogeco added the CCB:Approved Indicates code review and approval by community CCB label Sep 29, 2021
@astrogeco astrogeco changed the base branch from main to integration-candidate October 6, 2021 14:14
@astrogeco astrogeco added this to the cFS-Draco milestone Oct 6, 2021
astrogeco added a commit to astrogeco/osal that referenced this pull request Nov 3, 2021
astrogeco added a commit to astrogeco/cFS that referenced this pull request Nov 17, 2021
Combines:

nasa/cFE#2001
nasa/osal#1191
nasa/PSP#318

Includes:

- nasa/cFE#1663, Use cfe time clock state enum t in cmd/tlm and handling
- nasa/cFE#1973, EVS functional test add for different event types
- nasa/cFE#1954, Patch for recursive event loop
- nasa/cFE#1911, CFE_ES_MemAddOff structure to associated CFE_ES_MemAddress_t and CFE_ES_MemOffset_t
- nasa/cFE#1986, Avoid aliasing warnings
- nasa/cFE#1975, Message ID type improvements
- nasa/cFE#1974, CFE_SB_ValueToMsgId/MsgIdToValue wrappers
- nasa/cFE#1663, Use CFE_TIME_ClockState_Enum_t in cmd/tlm and handling
- nasa/cFE#1995, Consolidate repeated MSG stub setup in sb_UT
- nasa/cFE#1873, Return type conversions in CFE_ES_GetTaskName
- nasa/cFE#1966, Better message type pointer conversion
- nasa/cFE#2002, Replacing hardcoded message limit in TIME services
- nasa/cFE#1909, Use macro in CFE_ResourceId_IsDefined
- nasa/cFE#1999, Checking against IsNewOffset only

- nasa/osal#1186, Add Duplicate Check to Local Unit Test
- nasa/osal#1178, Rename OS_XXXTime to OS_XXXLocalTime in comments
- nasa/osal#1168, Fix vxWorks intLib stub aliasing issue
- nasa/osal#1169, Recognize ifdef __cplusplus
- nasa/osal#1180, Remove extern in stub prototypes
- nasa/osal#1112, Add typedef for OSAL status codes

- nasa/PSP#301, Sleep before exit when printing
- nasa/PSP#314, Check the address in PSP get segment stubs

- nasa/elf2cfetbl#89, Check get_sh_entsize(SectionHeader) value

- nasa/cFS-GroundSystem#197, Free Address Info for Leak

- nasa/sch_lab#95, use separate address variable

- nasa/sch_lab#94, Use CFE_MSG_PTR conversion macro
- nasa/sample_app#157, Use CFE_MSG_PTR conversion macro
- nasa/ci_lab#95, Use CFE_MSG_PTR conversion macro
- nasa/to_lab#107, Use CFE_MSG_PTR conversion macro

- nasa/elf2cfetbl#93, Check get_sh_entsize(SectionHeader) value

Co-authored by: Jacob Hageman skliper@no-reply.github.com
Co-authored by: Joseph Hickey jphickey@no-reply.github.com
Co-authored by: Ariel Adams ArielSAdamsNASA@no-reply.github.com

Co-authored by: Paul pavll@no-reply.github.com
Co-authored by: Zachary Gonzalez zachar1a@no-reply.github.com
Co-authored by: Sam Price thesamprice@no-reply.github.com
Co-authored by: Shefali Sharma Shefali321@no-reply.github.com
astrogeco added a commit to astrogeco/cFS that referenced this pull request Nov 18, 2021
Combines:

nasa/cFE#2001
nasa/osal#1191
nasa/PSP#318

Includes:

- nasa/cFE#1663, Use cfe time clock state enum t in cmd/tlm and handling
- nasa/cFE#1973, EVS functional test add for different event types
- nasa/cFE#1954, Patch for recursive event loop
- nasa/cFE#1911, CFE_ES_MemAddOff structure to associated CFE_ES_MemAddress_t and CFE_ES_MemOffset_t
- nasa/cFE#1986, Avoid aliasing warnings
- nasa/cFE#1975, Message ID type improvements
- nasa/cFE#1974, CFE_SB_ValueToMsgId/MsgIdToValue wrappers
- nasa/cFE#1663, Use CFE_TIME_ClockState_Enum_t in cmd/tlm and handling
- nasa/cFE#1995, Consolidate repeated MSG stub setup in sb_UT
- nasa/cFE#1873, Return type conversions in CFE_ES_GetTaskName
- nasa/cFE#1966, Better message type pointer conversion
- nasa/cFE#2002, Replacing hardcoded message limit in TIME services
- nasa/cFE#1909, Use macro in CFE_ResourceId_IsDefined
- nasa/cFE#1999, Checking against IsNewOffset only

- nasa/osal#1186, Add Duplicate Check to Local Unit Test
- nasa/osal#1178, Rename OS_XXXTime to OS_XXXLocalTime in comments
- nasa/osal#1168, Fix vxWorks intLib stub aliasing issue
- nasa/osal#1169, Recognize ifdef __cplusplus
- nasa/osal#1180, Remove extern in stub prototypes
- nasa/osal#1112, Add typedef for OSAL status codes

- nasa/PSP#301, Sleep before exit when printing
- nasa/PSP#314, Check the address in PSP get segment stubs

- nasa/elf2cfetbl#89, Check get_sh_entsize(SectionHeader) value

- nasa/cFS-GroundSystem#197, Free Address Info for Leak

- nasa/sch_lab#95, use separate address variable

- nasa/sch_lab#94, Use CFE_MSG_PTR conversion macro
- nasa/sample_app#157, Use CFE_MSG_PTR conversion macro
- nasa/ci_lab#95, Use CFE_MSG_PTR conversion macro
- nasa/to_lab#107, Use CFE_MSG_PTR conversion macro

- nasa/elf2cfetbl#93, Check get_sh_entsize(SectionHeader) value

Co-authored by: Jacob Hageman <skliper@no-reply.github.com>
Co-authored by: Joseph Hickey <jphickey@no-reply.github.com>
Co-authored by: Ariel Adams <ArielSAdamsNASA@no-reply.github.com>

Co-authored by: Paul <pavll@no-reply.github.com>
Co-authored by: Zachary Gonzalez <zachar1a@no-reply.github.com>
Co-authored by: Sam Price <thesamprice@no-reply.github.com>
Co-authored by: Shefali Sharma <Shefali321@no-reply.github.com>
astrogeco added a commit to astrogeco/cFS that referenced this pull request Nov 18, 2021
Combines:

nasa/cFE#2001
nasa/osal#1191
nasa/PSP#318

Includes:

- nasa/cFE#1663, Use cfe time clock state enum t in cmd/tlm and handling
- nasa/cFE#1973, EVS functional test add for different event types
- nasa/cFE#1954, Patch for recursive event loop
- nasa/cFE#1911, CFE_ES_MemAddOff structure to associated CFE_ES_MemAddress_t and CFE_ES_MemOffset_t
- nasa/cFE#1986, Avoid aliasing warnings
- nasa/cFE#1975, Message ID type improvements
- nasa/cFE#1974, CFE_SB_ValueToMsgId/MsgIdToValue wrappers
- nasa/cFE#1663, Use CFE_TIME_ClockState_Enum_t in cmd/tlm and handling
- nasa/cFE#1995, Consolidate repeated MSG stub setup in sb_UT
- nasa/cFE#1873, Return type conversions in CFE_ES_GetTaskName
- nasa/cFE#1966, Better message type pointer conversion
- nasa/cFE#2002, Replacing hardcoded message limit in TIME services
- nasa/cFE#1909, Use macro in CFE_ResourceId_IsDefined
- nasa/cFE#1999, Checking against IsNewOffset only

- nasa/osal#1186, Add Duplicate Check to Local Unit Test
- nasa/osal#1178, Rename OS_XXXTime to OS_XXXLocalTime in comments
- nasa/osal#1168, Fix vxWorks intLib stub aliasing issue
- nasa/osal#1169, Recognize ifdef __cplusplus
- nasa/osal#1180, Remove extern in stub prototypes
- nasa/osal#1112, Add typedef for OSAL status codes

- nasa/PSP#301, Sleep before exit when printing
- nasa/PSP#314, Check the address in PSP get segment stubs

- nasa/elf2cfetbl#89, Check get_sh_entsize(SectionHeader) value

- nasa/cFS-GroundSystem#197, Free Address Info for Leak

- nasa/sch_lab#95, use separate address variable

- nasa/sch_lab#94, Use CFE_MSG_PTR conversion macro
- nasa/sample_app#157, Use CFE_MSG_PTR conversion macro
- nasa/ci_lab#95, Use CFE_MSG_PTR conversion macro
- nasa/to_lab#107, Use CFE_MSG_PTR conversion macro

- nasa/elf2cfetbl#93, Check get_sh_entsize(SectionHeader) value

Co-authored-by: Jacob Hageman <skliper@no-reply.github.com>
Co-authored-by: Joseph Hickey <jphickey@no-reply.github.com>
Co-authored-by: Ariel Adams <ArielSAdamsNASA@no-reply.github.com>
Co-authored-by: Paul <pavll@no-reply.github.com>
Co-authored-by: Zachary Gonzalez <zachar1a@no-reply.github.com>
Co-authored-by: Sam Price <thesamprice@no-reply.github.com>
Co-authored-by: Shefali Sharma <Shefali321@no-reply.github.com>
astrogeco added a commit to astrogeco/cFS that referenced this pull request Nov 18, 2021
Combines:

nasa/cFE#2001
nasa/osal#1191
nasa/PSP#318

Includes:

- nasa/cFE#1663, Use cfe time clock state enum t in cmd/tlm and handling
- nasa/cFE#1973, EVS functional test add for different event types
- nasa/cFE#1954, Patch for recursive event loop
- nasa/cFE#1911, CFE_ES_MemAddOff structure to associated CFE_ES_MemAddress_t and CFE_ES_MemOffset_t
- nasa/cFE#1986, Avoid aliasing warnings
- nasa/cFE#1975, Message ID type improvements
- nasa/cFE#1974, CFE_SB_ValueToMsgId/MsgIdToValue wrappers
- nasa/cFE#1663, Use CFE_TIME_ClockState_Enum_t in cmd/tlm and handling
- nasa/cFE#1995, Consolidate repeated MSG stub setup in sb_UT
- nasa/cFE#1873, Return type conversions in CFE_ES_GetTaskName
- nasa/cFE#1966, Better message type pointer conversion
- nasa/cFE#2002, Replacing hardcoded message limit in TIME services
- nasa/cFE#1909, Use macro in CFE_ResourceId_IsDefined
- nasa/cFE#1999, Checking against IsNewOffset only

- nasa/osal#1186, Add Duplicate Check to Local Unit Test
- nasa/osal#1178, Rename OS_XXXTime to OS_XXXLocalTime in comments
- nasa/osal#1168, Fix vxWorks intLib stub aliasing issue
- nasa/osal#1169, Recognize ifdef __cplusplus
- nasa/osal#1180, Remove extern in stub prototypes
- nasa/osal#1112, Add typedef for OSAL status codes

- nasa/PSP#301, Sleep before exit when printing
- nasa/PSP#314, Check the address in PSP get segment stubs

- nasa/elf2cfetbl#89, Check get_sh_entsize(SectionHeader) value

- nasa/cFS-GroundSystem#197, Free Address Info for Leak

- nasa/sch_lab#95, use separate address variable

- nasa/sch_lab#94, Use CFE_MSG_PTR conversion macro
- nasa/sample_app#157, Use CFE_MSG_PTR conversion macro
- nasa/ci_lab#95, Use CFE_MSG_PTR conversion macro
- nasa/to_lab#107, Use CFE_MSG_PTR conversion macro

- nasa/elf2cfetbl#93, Check get_sh_entsize(SectionHeader) value

Co-authored-by: Jacob Hageman <skliper@users.no-reply.github.com>
Co-authored-by: Joseph Hickey <jphickey@users.no-reply.github.com>
Co-authored-by: Ariel Adams <ArielSAdamsNASA@users.no-reply.github.com>
Co-authored-by: Paul <pavll@users.no-reply.github.com>
Co-authored-by: Zachary Gonzalez <zachar1a@users.no-reply.github.com>
Co-authored-by: Sam Price <thesamprice@users.no-reply.github.com>
Co-authored-by: Shefali Sharma <Shefali321@users.no-reply.github.com>
astrogeco added a commit to astrogeco/cFS that referenced this pull request Nov 18, 2021
Combines:

nasa/cFE#2001
nasa/osal#1191
nasa/PSP#318

Includes:

- nasa/cFE#1663, Use cfe time clock state enum t in cmd/tlm and handling
- nasa/cFE#1973, EVS functional test add for different event types
- nasa/cFE#1954, Patch for recursive event loop
- nasa/cFE#1911, CFE_ES_MemAddOff structure to associated CFE_ES_MemAddress_t and CFE_ES_MemOffset_t
- nasa/cFE#1986, Avoid aliasing warnings
- nasa/cFE#1975, Message ID type improvements
- nasa/cFE#1974, CFE_SB_ValueToMsgId/MsgIdToValue wrappers
- nasa/cFE#1663, Use CFE_TIME_ClockState_Enum_t in cmd/tlm and handling
- nasa/cFE#1995, Consolidate repeated MSG stub setup in sb_UT
- nasa/cFE#1873, Return type conversions in CFE_ES_GetTaskName
- nasa/cFE#1966, Better message type pointer conversion
- nasa/cFE#2002, Replacing hardcoded message limit in TIME services
- nasa/cFE#1909, Use macro in CFE_ResourceId_IsDefined
- nasa/cFE#1999, Checking against IsNewOffset only

- nasa/osal#1186, Add Duplicate Check to Local Unit Test
- nasa/osal#1178, Rename OS_XXXTime to OS_XXXLocalTime in comments
- nasa/osal#1168, Fix vxWorks intLib stub aliasing issue
- nasa/osal#1169, Recognize ifdef __cplusplus
- nasa/osal#1180, Remove extern in stub prototypes
- nasa/osal#1112, Add typedef for OSAL status codes

- nasa/PSP#301, Sleep before exit when printing
- nasa/PSP#314, Check the address in PSP get segment stubs

- nasa/elf2cfetbl#89, Check get_sh_entsize(SectionHeader) value

- nasa/cFS-GroundSystem#197, Free Address Info for Leak

- nasa/sch_lab#95, use separate address variable

- nasa/sch_lab#94, Use CFE_MSG_PTR conversion macro
- nasa/sample_app#157, Use CFE_MSG_PTR conversion macro
- nasa/ci_lab#95, Use CFE_MSG_PTR conversion macro
- nasa/to_lab#107, Use CFE_MSG_PTR conversion macro

- nasa/elf2cfetbl#93, Check get_sh_entsize(SectionHeader) value

Co-authored-by: Jacob Hageman       <skliper@users.no-reply.github.com>
Co-authored-by: Joseph Hickey       <jphickey@users.no-reply.github.com>
Co-authored-by: Ariel Adams         <ArielSAdamsNASA@users.no-reply.github.com>
Co-authored-by: Paul                <pavll@users.no-reply.github.com>
Co-authored-by: Zachary Gonzalez    <zachar1a@users.no-reply.github.com>
Co-authored-by: Sam Price           <thesamprice@users.no-reply.github.com>
Co-authored-by: Shefali Sharma      <Shefali321@users.no-reply.github.com>
astrogeco added a commit to nasa/cFS that referenced this pull request Nov 18, 2021
Combines:

nasa/cFE#2001
nasa/osal#1191
nasa/PSP#318

Includes:

- nasa/cFE#1663, Use cfe time clock state enum t in cmd/tlm and handling
- nasa/cFE#1973, EVS functional test add for different event types
- nasa/cFE#1954, Patch for recursive event loop
- nasa/cFE#1911, CFE_ES_MemAddOff structure to associated CFE_ES_MemAddress_t and CFE_ES_MemOffset_t
- nasa/cFE#1986, Avoid aliasing warnings
- nasa/cFE#1975, Message ID type improvements
- nasa/cFE#1974, CFE_SB_ValueToMsgId/MsgIdToValue wrappers
- nasa/cFE#1663, Use CFE_TIME_ClockState_Enum_t in cmd/tlm and handling
- nasa/cFE#1995, Consolidate repeated MSG stub setup in sb_UT
- nasa/cFE#1873, Return type conversions in CFE_ES_GetTaskName
- nasa/cFE#1966, Better message type pointer conversion
- nasa/cFE#2002, Replacing hardcoded message limit in TIME services
- nasa/cFE#1909, Use macro in CFE_ResourceId_IsDefined
- nasa/cFE#1999, Checking against IsNewOffset only

- nasa/osal#1186, Add Duplicate Check to Local Unit Test
- nasa/osal#1178, Rename OS_XXXTime to OS_XXXLocalTime in comments
- nasa/osal#1168, Fix vxWorks intLib stub aliasing issue
- nasa/osal#1169, Recognize ifdef __cplusplus
- nasa/osal#1180, Remove extern in stub prototypes
- nasa/osal#1112, Add typedef for OSAL status codes

- nasa/PSP#301, Sleep before exit when printing
- nasa/PSP#314, Check the address in PSP get segment stubs

- nasa/elf2cfetbl#89, Check get_sh_entsize(SectionHeader) value

- nasa/cFS-GroundSystem#197, Free Address Info for Leak

- nasa/sch_lab#95, use separate address variable

- nasa/sch_lab#94, Use CFE_MSG_PTR conversion macro
- nasa/sample_app#157, Use CFE_MSG_PTR conversion macro
- nasa/ci_lab#95, Use CFE_MSG_PTR conversion macro
- nasa/to_lab#107, Use CFE_MSG_PTR conversion macro

- nasa/elf2cfetbl#93, Check get_sh_entsize(SectionHeader) value

Co-authored-by: Jacob Hageman       <skliper@users.noreply.github.com>
Co-authored-by: Joseph Hickey       <jphickey@users.noreply.github.com>
Co-authored-by: Ariel Adams         <ArielSAdamsNASA@users.noreply.github.com>
Co-authored-by: Paul                <pavll@users.noreply.github.com>
Co-authored-by: Zachary Gonzalez    <zachar1a@users.noreply.github.com>
Co-authored-by: Sam Price           <thesamprice@users.noreply.github.com>
Co-authored-by: Shefali Sharma      <Shefali321@users.noreply.github.com>
astrogeco added a commit to astrogeco/cFS that referenced this pull request Nov 18, 2021
Combines:

nasa/cFE#2001
nasa/osal#1191
nasa/PSP#318

nasa/ci_lab#101
nasa/sch_lab#102
nasa/to_lab#112
nasa/sample_app#163
nasa/cFS-GroundSystem#201
nasa/elf2cfetbl#98

Includes:

*cFE*

- nasa/cFE#1663, Use cfe time clock state enum t in cmd/tlm and handling
- nasa/cFE#1973, EVS functional test add for different event types
- nasa/cFE#1954, Patch for recursive event loop
- nasa/cFE#1911, CFE_ES_MemAddOff structure to associated CFE_ES_MemAddress_t and CFE_ES_MemOffset_t
- nasa/cFE#1986, Avoid aliasing warnings
- nasa/cFE#1975, Message ID type improvements
- nasa/cFE#1974, CFE_SB_ValueToMsgId/MsgIdToValue wrappers
- nasa/cFE#1663, Use CFE_TIME_ClockState_Enum_t in cmd/tlm and handling
- nasa/cFE#1995, Consolidate repeated MSG stub setup in sb_UT
- nasa/cFE#1873, Return type conversions in CFE_ES_GetTaskName
- nasa/cFE#1966, Better message type pointer conversion
- nasa/cFE#2002, Replacing hardcoded message limit in TIME services
- nasa/cFE#1909, Use macro in CFE_ResourceId_IsDefined
- nasa/cFE#1999, Checking against IsNewOffset only

*osal*

- nasa/osal#1186, Add Duplicate Check to Local Unit Test
- nasa/osal#1178, Rename OS_XXXTime to OS_XXXLocalTime in comments
- nasa/osal#1168, Fix vxWorks intLib stub aliasing issue
- nasa/osal#1169, Recognize ifdef __cplusplus
- nasa/osal#1180, Remove extern in stub prototypes
- nasa/osal#1112, Add typedef for OSAL status codes

*PSP*

- nasa/PSP#301, Sleep before exit when printing
- nasa/PSP#314, Check the address in PSP get segment stubs

*Tools*

- nasa/elf2cfetbl#89, Check get_sh_entsize(SectionHeader) value
- nasa/elf2cfetbl#93, Check get_sh_entsize(SectionHeader) value
- nasa/cFS-GroundSystem#197, Free Address Info for Leak

*Apps*

- nasa/sch_lab#95, use separate address variable
- nasa/sch_lab#94, Use CFE_MSG_PTR conversion macro
- nasa/sample_app#157, Use CFE_MSG_PTR conversion macro
- nasa/ci_lab#95, Use CFE_MSG_PTR conversion macro
- nasa/to_lab#107, Use CFE_MSG_PTR conversion macro

Co-authored-by: Jacob Hageman       <skliper@users.noreply.github.com>
Co-authored-by: Joseph Hickey       <jphickey@users.noreply.github.com>
Co-authored-by: Ariel Adams         <ArielSAdamsNASA@users.noreply.github.com>
Co-authored-by: Paul                <pavll@users.noreply.github.com>
Co-authored-by: Zachary Gonzalez    <zachar1a@users.noreply.github.com>
Co-authored-by: Sam Price           <thesamprice@users.noreply.github.com>
Co-authored-by: Shefali Sharma      <Shefali321@users.noreply.github.com>
@astrogeco
Copy link
Contributor

Merged in 4a2cadd

@astrogeco astrogeco closed this Dec 8, 2021
@jphickey jphickey deleted the fix-1166-stubgen-ifdef-cplusplus branch February 23, 2022 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CCB:Approved Indicates code review and approval by community CCB draco-rc1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UT assert stub generator bypasses functions marked extern "C"
3 participants