michallenc opened a new pull request, #19221:
URL: https://github.com/apache/nuttx/pull/19221

   ## Summary
   Generic `stdc_` functions use `_Generic` macro, but this requires the type 
specific functions `stdc_*_uc`, `stdc_*_ul` and so on to be functions, not just 
another macro definitions.
   
   This commit fixes the issue by ensuring all type specific functions are 
static inline functions, not macro definitions.
   
   ## Impact
   
   Fixes the compilation error of `stdc_leading_ones`, `stdc_trailing_ones`, 
`stdc_count_zeros`, `stdc_count_ones`,
   `stdc_has_single_bit` and `stdc_bit_width` functions.
   
   ## Testing
   
   Testing application is 
[here](https://github.com/michallenc/incubator-nuttx-apps/blob/stdbit-test/testing/libc/stdbit/stdbit.c).
 I will create a separate merge request for tests later.
   
   Compile errors before the fix:
   
   ```
   Create version.h
   CC:  stdbit.c In file included from stdbit.c:31:
   stdbit.c: In function ‘leading_ones’:
   stdbit.c:207:14: error: ‘stdc_leading_ones_uc’ undeclared (first use in this 
function); did you mean ‘stdc_leading_zeros_uc’?
     207 |       ret2 = stdc_leading_ones(uc);
         |              ^~~~~~~~~~~~~~~~~
   stdbit.c:207:14: note: each undeclared identifier is reported only once for 
each function it appears in
   stdbit.c: In function ‘trailing_ones’:
   stdbit.c:385:14: error: ‘stdc_trailing_ones_uc’ undeclared (first use in 
this function); did you mean ‘stdc_trailing_zeros_uc’?
     385 |       ret2 = stdc_trailing_ones(uc);
         |              ^~~~~~~~~~~~~~~~~~
   stdbit.c: In function ‘count_zeros’:
   stdbit.c:830:14: error: ‘stdc_count_zeros_uc’ undeclared (first use in this 
function); did you mean ‘stdc_leading_zeros_uc’?
     830 |       ret2 = stdc_count_zeros(uc);
         |              ^~~~~~~~~~~~~~~~
   stdbit.c: In function ‘count_ones’:
   stdbit.c:919:14: error: ‘stdc_count_ones_uc’ undeclared (first use in this 
function)
     919 |       ret2 = stdc_count_ones(uc);
         |              ^~~~~~~~~~~~~~~
   stdbit.c: In function ‘has_single_bit’:
   stdbit.c:1008:14: error: ‘stdc_has_single_bit_uc’ undeclared (first use in 
this function); did you mean ‘has_single_bit’?
    1008 |       ret2 = stdc_has_single_bit(uc);
         |              ^~~~~~~~~~~~~~~~~~~
   stdbit.c: In function ‘bit_width’:
   stdbit.c:1097:14: error: ‘stdc_bit_width_uc’ undeclared (first use in this 
function); did you mean ‘stdc_bit_ceil_uc’?
    1097 |       ret2 = stdc_bit_width(uc);
         |              ^~~~~~~~~~~~~~
   make[2]: *** [/path/to/nuttx/apps/Application.mk:330: 
stdbit.c.home.michal.Michal.projects.nuttx.apps.testing.libc.stdbit.o] Error 1
   make[1]: *** [Makefile:54: /path/to/nuttx/apps/testing/libc/stdbit_all] 
Error 2
   make[1]: *** Waiting for unfinished jobs....
   make: *** [tools/LibTargets.mk:248: /path/to/nuttx/apps/libapps.a] Error 2
   make: *** Waiting for unfinished jobs....
   ```
   
   The application compiles and all tests pass after the fix.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to