Skip to content

[HELP] the type of INT32_C(0) is not int32_t in xtensa #17992

@Y334275

Description

@Y334275

Description

When I was trying to replace the NuttX version that PX4 depends on with 12.12, I encountered some compilation errors. Here is the specific compilation error:

PX4-Autopilot/src/modules/navigator/mission_base.cpp:76:60: error: no matching function for call to 'constrain(int32_t&, long long int, long int)'  
  76 |                 const int32_t start_index = `math::constrain`(_mission.current_seq, `INT32_C(0)`, int32_t(_mission.count) - 1);  
     |                                             ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
compilation terminated due to -Wfatal-errors  

In this case, math::constrain is a template function that expects all arguments to be of a single type (which should be int32_t here). However, the type of INT32_C(0) is not int32_t.

I searched for INT32_C and found its definition in arch/xtensa/include/inttypes.h:

#define INT32_C(x)  x ## ll  
#define INT64_C(x)  x ## ll  

This shows its definition is the same as INT64_C, both being long long int. But the _int32_t defined in xtensa is long int (in arch/xtensa/include/types.h). Is this a mistake?

Verification

  • I have verified before submitting the report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions