Project

General

Profile

Actions

Bug #3748

open

zfs headers should be C++ compatible

Added by Will Andrews over 10 years ago. Updated over 10 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Start date:
2013-04-23
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:
External Bug:

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.

Actions #1

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.
Actions #2

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.

Actions

Also available in: Atom PDF