danielappiagyei-bc commented on issue #10556:
URL: https://github.com/apache/nuttx/issues/10556#issuecomment-1712907771

   **RE: replacing the usage of  C++ keywords from C headers**
   Replacing even just `this` and `public` from 
https://github.com/apache/nuttx/blob/master/include/nuttx/streams.h will be a 
big change that touches a lot of files. That header defines a bunch of `stream` 
struct types that have a field named `public` (e.g., 
[here](https://github.com/apache/nuttx/blob/master/include/nuttx/streams.h#L140)).
 Therefore, any C source or header that includes stream.h and uses stream 
struct objects will need to be updated to use the new field name as well. I 
don't mind coming up with a renaming patch and submitting a PR, but I want to 
make sure that you all will be okay with such a big change beforehand.
   
   Here are just a few examples I got when I:
   - added the `-Wc++-compat` flag to `CFLAGS` in [IMXRT's 
Make.defs](https://github.com/apache/nuttx/blob/master/boards/arm/imxrt/imxrt1064-evk/scripts/Make.defs#L43)
   - added `CONFIG_STREAM_RTT=y` to [IMXRT's 
defconfig](https://github.com/apache/nuttx/blob/master/boards/arm/imxrt/imxrt1064-evk/configs/nsh/defconfig)
   - and added `#include <nuttx/segger/rtt.h>` to [nsh.h in 
nuttx-apps](https://github.com/apache/nuttx-apps/blob/master/nshlib/nsh.h)
   
   
   ```
   stdio/lib_vdprintf.c:60:51: warning: identifier 'public' conflicts with C++ 
keyword [-Wc++-compat]                                                          
                                                       
      60 |   lib_bufferedoutstream(&outstream, &rawoutstream.public);           
                                                                                
                                                      
         |                                                   ^~~~~~             
                                                                                
                                                      
   stdio/lib_vdprintf.c:61:33: warning: identifier 'public' conflicts with C++ 
keyword [-Wc++-compat]                                                          
                                                       
      61 |   ret = lib_vsprintf(&outstream.public, fmt, ap);                    
                                                                                
                                                      
         |                                 ^~~~~~                               
                                                                                
                                                      
   In file included from 
/home/daniel.appiagyei/projects/dan-nuttx/nuttx/libs/libc/libc.h:39,            
                                                                                
                             
                    from stdio/lib_vdprintf.c:45:                               
                                                                                
                                                      
   stdio/lib_vdprintf.c:62:31: warning: identifier 'public' conflicts with C++ 
keyword [-Wc++-compat]                                                          
                                                       
      62 |   lib_stream_flush(&outstream.public);                               
                                                                                
                                                      
         |                               ^~~~~~                                 
                                                                                
                                                      
   stdio/lib_vdprintf.c:62:31: warning: identifier 'public' conflicts with C++ 
keyword [-Wc++-compat]                                                          
                                                       
      62 |   lib_stream_flush(&outstream.public);                               
                                                                                
                                                      
         |                               ^~~~~~                                 
                                                                                
                                                      
   CC:  stdio/lib_vsscanf.c stdio/lib_vsscanf.c: In function 'vsscanf':         
                                                                                
                                                      
   stdio/lib_vsscanf.c:53:60: warning: identifier 'public' conflicts with C++ 
keyword [-Wc++-compat]                                                          
                                                        
      53 |   n = lib_vscanf((FAR struct lib_instream_s *)&meminstream.public, 
NULL, 
   ```
   
   Is such a big change something you'd all be okay with?
   
   > The code snippet is more like rtt syslog channel
   
   Got it, thanks!


-- 
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