All of lore.kernel.org
 help / color / mirror / Atom feed
* check idea: include sparse as a library in C++
@ 2021-06-22  6:45 Ke Du
  2021-07-26 18:28 ` Luc Van Oostenryck
  0 siblings, 1 reply; 6+ messages in thread
From: Ke Du @ 2021-06-22  6:45 UTC (permalink / raw)
  To: linux-sparse; +Cc: Xiao Jia

Hi,

I want to include sparse as a library in C++ and access fields of the 
structs such as symbol and expression directly, but some of the 
variables in sparse are keywords in C++ so they cannot be included in 
C++ directly. I have several fixes below that are not ideal, and any 
feedback is appreciated.

1. Append an underscore to C++ keywords, for instance change new to 
new_. The change only involves the code that I included so there might 
be some C++ keywords in sparse that are unchanged.

2. Replace every keyword with a macro:

     #ifdef __cplusplus
     #define NEW new_
     #else
     #define NEW new
     #endif

Similar to solution 1, this is not complete, and both 1 and 2 involves 
about 200 changes already.

3. When including sparse header files, guard them with

     #define new new_
     #include ...
     #define new_ new

This does not involve change to sparse but it imposes weird restriction 
to the ordering of other C++ libraries that I do not understand at all.

I can send the patches if one of the fixes is acceptable. Alternatively, 
if there is a better way, please let me know.

Cheers,
-- Ke

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-17  9:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-22  6:45 check idea: include sparse as a library in C++ Ke Du
2021-07-26 18:28 ` Luc Van Oostenryck
2021-08-13  1:25   ` [PATCH 0/2] fixes for using sparse as a C++ library Ke Du
2021-08-13  1:25     ` [PATCH 1/2] expose more functions to C++ in header files Ke Du
2021-11-17  9:44       ` Xiao Jia
2021-08-13  1:25     ` [PATCH 2/2] make implicit type conversion explicit Ke Du

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.