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

[BUG] Improper use of headers and includes. #959

Closed
phelter opened this issue Jul 8, 2023 · 3 comments
Closed

[BUG] Improper use of headers and includes. #959

phelter opened this issue Jul 8, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@phelter
Copy link
Contributor

phelter commented Jul 8, 2023

Describe the bug
The way headers are included they have to be in a particular order and not all headers that define types and parameters are added to the headers that consume those types/definitions.

Also the:

    #ifdef __cplusplus
        extern "C" {
    #endif

should be AFTER any other includes in the header and not before. Otherwise if a header is missing the extern-C you may have 2 definitions of the same function (one for extern-C style) and one for native Cpp mangled name.

Target

  • Development board: None - Linux
  • Instruction Set Architecture: x86/amd64
  • IDE and version: N/A - cmake builds
  • Toolchain and version: clang-14

Host

  • Host OS: Ubuntu
  • Version: 22.04

To Reproduce

  • Use project where you have the following include order:
/* FreeRTOS+TCP includes. */
#include "FreeRTOS_DHCP.h"
#include "FreeRTOS_IP.h"
#include "FreeRTOS_Sockets.h"
  • Attempt to compile and observe errors where used:
freertos_plus_tcp-src/source/include/FreeRTOS_DHCPv6.h:145:5: error: unknown type name 'eDHCPState_t'
freertos_plus_tcp-src/source/include/FreeRTOS_Routing.h:51:65: error: unknown type name 'NetworkBufferDescriptor_t'
freertos_plus_tcp-src/source/include/FreeRTOS_Routing.h:159:9: error: unknown type name 'MACAddress_t'; did you mean 'IP_Address_t'?
freertos_plus_tcp-src/source/include/FreeRTOS_Routing.h:179:13: error: unknown type name 'IPTimer_t'
freertos_plus_tcp-src/source/include/FreeRTOS_Routing.h:182:13: error: unknown type name 'DHCPData_t'
freertos_plus_tcp-src/source/include/FreeRTOS_Routing.h:246:59: error: unknown type name 'MACAddress_t'; did you mean 'IP_Address_t'?
freertos_plus_tcp-src/source/include/FreeRTOS_Routing.h:288:60: error: use of undeclared identifier 'ipIP_ADDRESS_LENGTH_BYTES'
freertos_plus_tcp-src/source/include/FreeRTOS_Routing.h:289:58: error: use of undeclared identifier 'ipIP_ADDRESS_LENGTH_BYTES'
freertos_plus_tcp-src/source/include/FreeRTOS_Routing.h:290:65: error: use of undeclared identifier 'ipIP_ADDRESS_LENGTH_BYTES'
freertos_plus_tcp-src/source/include/FreeRTOS_Routing.h:291:67: error: use of undeclared identifier 'ipIP_ADDRESS_LENGTH_BYTES'
freertos_plus_tcp-src/source/include/FreeRTOS_Routing.h:292:61: error: use of undeclared identifier 'ipMAC_ADDRESS_LENGTH_BYTES'
freertos_plus_tcp-src/source/include/FreeRTOS_Routing.h:303:70: error: use of undeclared identifier 'ipMAC_ADDRESS_LENGTH_BYTES'

Please add what each header uses or provide an explicit documentation on the requirements of header ordering for this project to work.

Expected behavior
Any header can be added in any order and it will work. Using header guards for ensuring something doesn't get added twice.

Screenshots
N/A

Wireshark logs
N/A

Additional context
N/A

@phelter phelter added the bug Something isn't working label Jul 8, 2023
@moninom1
Copy link
Member

HI @phelter,
Thank you for bringing this to our attention! We will be looking further into this issue as soon as we can, thank you for your patience!”

@moninom1
Copy link
Member

Hi @phelter,
We looked into the issue and here are our observations :

  1. Yeah extern “C” block can be moved after the #includes and we will create a PR for the same.
  2. For order of header includes,, we see some files have the issue and we working on finding an efficient way to fix it.

@moninom1
Copy link
Member

Hi @phelter, Both the issue's PR are merged, hence closing the PR. Thank you for reporting the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants