[lustre-discuss] Compile a C++ app. using the Lustre API
Dilger, Andreas
andreas.dilger at intel.com
Wed Mar 15 15:50:34 PDT 2017
On Mar 15, 2017, at 15:22, François Tessier <ftessier at anl.gov> wrote:
>
> I get the same errors with g++ (v. 6.3). I can't find what kind of compiler flag I can use to be able to compile this. It clearly comes from how C++ deals with enum. The solutions I've found consist in "static_casting" the int values... Modifying my local version of lustre_user.h is probably not the best idea :-)
Have you tried adding the standard wrappers at the start and end of the lustre_user.h header:
#ifdef __cplusplus
extern "C" {
#endif
:
<rest of header>
#ifdef __cplusplus
}
#endif
I thought we had added those long ago, but I don't see them in the header today. If that fixes your problem, please file an LU ticket at https://jira.hpdd.intel.com/ (and ideally a patch at https://review.whamcloud.com/ too) and we can get this added to the header.
In the meantime, you could also wrap your "#include <lustre/lustre_user.h>" similarly.
Cheers, Andreas
> On 03/15/2017 02:14 PM, Patrick Farrell wrote:
>> It looks like your compiler is being fussier than the C compiler.
>>
>> Specifically, the problem appears to be with the enum type. The C compiler is happy to let pass using a short (cr_flags) where an enum is called for (argument to changelog_rec_offset). In C, I think an enum is an int (so passing in a short like this is always fine). I guess in C++ either enum is not an int, or it's just fussier.
>>
>> There might be a compiler flag to make it not error on this? I am not familiar with icpc, so I can't help with specifics.
>>
>> You might also try a different C++ compiler, to see if it has a different attitude towards that error.
>>
>> One further thought, though:
>> This is a C header. Presumably, it is not intended to be included directly in a C++ project?
>>
>> - Patrick
>> From: lustre-discuss <lustre-discuss-bounces at lists.lustre.org> on behalf of François Tessier <ftessier at anl.gov>
>> Sent: Wednesday, March 15, 2017 2:00:31 PM
>> To: lustre-discuss at lists.lustre.org
>> Subject: [lustre-discuss] Compile a C++ app. using the Lustre API
>>
>> Hi All,
>>
>> I'm working on a piece of code using the Lustre API. To do so, I include
>> lustreapi.h. When I compile my code with a C compiler (icc), everything
>> is fine. However, when I compile it with a C++ compiler (icpc), I get
>> these errors:
>>
>> ---------------------------------
>>
>> In file included from /usr/include/lustre/lustreapi.h(47),
>> from topo.c(5):
>> /usr/include/lustre/lustre_user.h(914): error: argument of type "__u16={unsigned short}" is incompatible with parameter of type "changelog_rec_flags"
>> return changelog_rec_offset(rec->cr_flags);
>> ^
>>
>> In file included from /usr/include/lustre/lustreapi.h(47),
>> from topo.c(5):
>> /usr/include/lustre/lustre_user.h(925): error: a value of type "int" cannot be used to initialize an entity of type "changelog_rec_flags"
>> enum changelog_rec_flags crf = rec->cr_flags & CLF_VERSION;
>> ^
>>
>> In file included from /usr/include/lustre/lustreapi.h(47),
>> from topo.c(5):
>> /usr/include/lustre/lustre_user.h(935): error: a value of type "int" cannot be used to initialize an entity of type "changelog_rec_flags"
>> enum changelog_rec_flags crf = rec->cr_flags &
>> ^
>>
>> In file included from /usr/include/lustre/lustreapi.h(47),
>> from topo.c(5):
>> /usr/include/lustre/lustre_user.h(945): error: argument of type "int" is incompatible with parameter of type "changelog_rec_flags"
>> return (char *)rec + changelog_rec_offset(rec->cr_flags &
>> ^
>>
>> In file included from /usr/include/lustre/lustreapi.h(47),
>> from topo.c(5):
>> /usr/include/lustre/lustre_user.h(986): error: this operation on an enumerated type requires an applicable user-defined operator function
>> crf_wanted &= CLF_SUPPORTED;
>> ^
>>
>> In file included from /usr/include/lustre/lustreapi.h(47),
>> from topo.c(5):
>> /usr/include/lustre/lustre_user.h(997): error: argument of type "int" is incompatible with parameter of type "changelog_rec_flags"
>> changelog_rec_offset(crf_wanted & ~CLF_JOBID);
>> ^
>>
>> In file included from /usr/include/lustre/lustreapi.h(47),
>> from topo.c(5):
>> /usr/include/lustre/lustre_user.h(999): error: argument of type "int" is incompatible with parameter of type "changelog_rec_flags"
>> changelog_rec_offset(crf_wanted & ~(CLF_JOBID | CLF_RENAME));
>> ^
>>
>> Makefile:10: recipe for target 'topo' failed
>> make: *** [topo] Error 2
>>
>> ---------------------------------
>>
>> It's probably more a compiler issue than a Lustre one but a solution
>> could help other users or Lustre developers.
>>
>> Any idea?
>>
>> Thanks,
>>
>> François
>>
>>
>> --
>> --
>> François TESSIER, Ph.D.
>> Postdoctoral Appointee
>> Argonne National Laboratory
>> LCF Division - Bldg 240, 4E 19
>> Tel : +1 (630)-252-5068
>> http://www.francoistessier.info
>>
>> _______________________________________________
>> lustre-discuss mailing list
>> lustre-discuss at lists.lustre.org
>> http://lists.lustre.org/listinfo.cgi/lustre-discuss-lustre.org
>
> _______________________________________________
> lustre-discuss mailing list
> lustre-discuss at lists.lustre.org
> http://lists.lustre.org/listinfo.cgi/lustre-discuss-lustre.org
Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation
More information about the lustre-discuss
mailing list