Bug 43372

Summary: Broken struct ufs_args in ufsmount.h
Product: Base System Reporter: alex <alex>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 5.0-CURRENT   
Hardware: Any   
OS: Any   

Description alex 2002-09-25 22:00:08 UTC
ufsmount.h is broken for C++.  It uses a reserved keyword "export"
for a member of the struct ufs_args:
struct ufs_args {
        char    *fspec;                 /* block special device to mount */
        struct  export_args export;     /* network export information */
};

alex@zerogravity ~ $ cat ufsmount.cc 
extern "C" {
#include <sys/param.h>
#include <sys/mount.h>
#include <ufs/ufs/ufsmount.h>
}
alex@zerogravity ~ $ c++ --version
c++ (GCC) 3.2.1 [FreeBSD] 20020901 (prerelease)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

alex@zerogravity ~ $ cc -c ufsmount.cc 
In file included from ufsmount.cc:4:
/usr/include/ufs/ufs/ufsmount.h:45: syntax error before `export'

Fix: 

As a workaround, you can #define export _export before you include
ufsmount.h, and undefine it later.  This is an ugly hack, but working
for certain uses.

A real fix is to proberly name the member of the struct.
How-To-Repeat: 
see above
Comment 1 wollman 2002-09-26 00:02:58 UTC
<<On Wed, 25 Sep 2002 22:59:45 +0200 (CEST), Alexander Langer <alex@big.endian.de> said:

> A real fix is to proberly name the member of the struct.

A better fix is to only use C headers in C programs.

-GAWollman
Comment 2 alex 2002-09-26 01:37:58 UTC
Thus spake Garrett Wollman (wollman@lcs.mit.edu):

> > A real fix is to proberly name the member of the struct.
> A better fix is to only use C headers in C programs.

That's not always possible, e.g. we are needing the mount stuff for
libh, which is written in C++.

Alex
Comment 3 wollman 2002-09-26 02:34:26 UTC
<<On Thu, 26 Sep 2002 02:37:58 +0200, Alexander Langer <alex@big.endian.de> said:

> That's not always possible, e.g. we are needing the mount stuff for
> libh, which is written in C++.

Certainly it is: you can link your C++ program with a module written
in C that does what you want.

Although this particular interface has very few clients, we shouldn't
make a precedent that our C API has to change every time C++
introduces a new incompatibility.

-GAWollman
Comment 4 Craig Rodrigues freebsd_committer freebsd_triage 2006-06-03 05:59:43 UTC
State Changed
From-To: open->closed

In CURRENT and RELENG_6, the new nmount() API should 
be used for mounting UFS partitions.  It does not take 
a struct ufs_args as a parameter, so any problems with 
struct ufs_args will not be encountered, i.e. in C++ programs.