check idea: include sparse as a library in C++

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux