Bug #3748
openzfs headers should be C++ compatible
0%
Description
This enables ZFS to be used directly in C++ programs. The most notable current example is FreeBSD's zfsd, which is a ZFS fault-management daemon (currently exists as a project branch, but has been in use for some time).
The change should include a mechanism to ensure that C++ compatibility is retained over time. To that end, a C++ file should be added to ztest.
Updated by Will Andrews over 10 years ago
From the original change log:
Change 477353 by justing@justing-ns1 on 2011/02/04 10:11:30
Remove C constructs that are incompatible with C++ from various
OpenSolaris and ZFS header files. These changes are sufficient
to allow a C++ program to use the libzfs library.
Note: The majority of these files already included 'extern "C"'
declarations, so the intention of providing C++ compatibility
already existed even if it wasn't provided.
uts/common/fs/zfs/sys/dsl_pool.h:
uts/common/fs/zfs/sys/spa.h:
uts/common/fs/zfs/sys/zio.h:
Place comments around parameters in function declarations
that conflict with C++ keywords.
uts/common/fs/zfs/sys/zfs_ioctl.h:
In C, nested structures are visible in the global namespace,
but in C++, they take on the namespace of the structure in
which they are contained. Flatten nested structure
definitions within struct zfs_cmd so these structures are
visible in the global namespace when compiled in both
languages.
Updated by Will Andrews over 10 years ago
Changes made to ZFS should to retain C++ compatibility primarily involve renaming variable names that use C++ reserved words, e.g.:
- private: often used as a callback data argument name
- class: dedup table class, for example
- new: "new" things
Renaming these to be more specific should suffice.