Here is the workaround I found (based on static_cast<>()):
- make a local copy of lustre_user.h and lustreapi.h
- apply the attached patch on lustre_user.h
- add an include parameter in your CXXFLAGS pointing to these files
- compile with CC
It's clearly not the best solution but it's a working temporary band-aid...
++
François
On 03/16/2017 07:44 AM, François Tessier wrote:
> On 03/15/2017 05:50 PM, Dilger, Andreas wrote:
>> On Mar 15, 2017, at 15:22, François Tessier <[email protected]> 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.
> It doesn't fix the problem. I tried a more recent version of g++ or
> several compiler options to force the use of C++11 [1] but with no success.
>> Cheers, Andreas
> Cheers,
> François
>
> [1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf
>>> 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 <[email protected]> on behalf
>>>> of François Tessier <[email protected]>
>>>> Sent: Wednesday, March 15, 2017 2:00:31 PM
>>>> To: [email protected]
>>>> 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
>>>> [email protected]
>>>> http://lists.lustre.org/listinfo.cgi/lustre-discuss-lustre.org
>>> _______________________________________________
>>> lustre-discuss mailing list
>>> [email protected]
>>> http://lists.lustre.org/listinfo.cgi/lustre-discuss-lustre.org
>> Cheers, Andreas
>> --
>> Andreas Dilger
>> Lustre Principal Architect
>> Intel Corporation
>>
>>
>>
>>
>>
>>
>>
> _______________________________________________
> lustre-discuss mailing list
> [email protected]
> http://lists.lustre.org/listinfo.cgi/lustre-discuss-lustre.org
--- /usr/include/lustre/lustre_user.h 2017-02-17 03:43:53.000000000 +0000
+++ lustre_user.h 2017-03-16 14:55:10.257941000 +0000
@@ -911,7 +911,7 @@
static inline size_t changelog_rec_size(struct changelog_rec *rec)
{
- return changelog_rec_offset(rec->cr_flags);
+ return changelog_rec_offset(static_cast<changelog_rec_flags>(rec->cr_flags));
}
static inline size_t changelog_rec_varsize(struct changelog_rec *rec)
@@ -922,7 +922,7 @@
static inline
struct changelog_ext_rename *changelog_rec_rename(struct changelog_rec *rec)
{
- enum changelog_rec_flags crf = rec->cr_flags & CLF_VERSION;
+ enum changelog_rec_flags crf = static_cast<changelog_rec_flags>(rec->cr_flags & CLF_VERSION);
return (struct changelog_ext_rename *)((char *)rec +
changelog_rec_offset(crf));
@@ -932,8 +932,8 @@
static inline
struct changelog_ext_jobid *changelog_rec_jobid(struct changelog_rec *rec)
{
- enum changelog_rec_flags crf = rec->cr_flags &
- (CLF_VERSION | CLF_RENAME);
+ enum changelog_rec_flags crf = static_cast<changelog_rec_flags>(rec->cr_flags &
+ (CLF_VERSION | CLF_RENAME));
return (struct changelog_ext_jobid *)((char *)rec +
changelog_rec_offset(crf));
@@ -942,8 +942,8 @@
/* The name follows the rename and jobid extensions, if present */
static inline char *changelog_rec_name(struct changelog_rec *rec)
{
- return (char *)rec + changelog_rec_offset(rec->cr_flags &
- CLF_SUPPORTED);
+ return (char *)rec + changelog_rec_offset(static_cast<changelog_rec_flags>(rec->cr_flags &
+ CLF_SUPPORTED));
}
static inline size_t changelog_rec_snamelen(struct changelog_rec *rec)
@@ -983,7 +983,7 @@
char *jid_mov;
char *rnm_mov;
- crf_wanted &= CLF_SUPPORTED;
+ crf_wanted = static_cast<changelog_rec_flags>(crf_wanted & CLF_SUPPORTED);
if ((rec->cr_flags & CLF_SUPPORTED) == crf_wanted)
return;
@@ -994,9 +994,9 @@
/* Locations of jobid and rename extensions in the remapped record */
jid_mov = (char *)rec +
- changelog_rec_offset(crf_wanted & ~CLF_JOBID);
+ changelog_rec_offset(static_cast<changelog_rec_flags>(crf_wanted & ~CLF_JOBID));
rnm_mov = (char *)rec +
- changelog_rec_offset(crf_wanted & ~(CLF_JOBID | CLF_RENAME));
+ changelog_rec_offset(static_cast<changelog_rec_flags>(crf_wanted & ~(CLF_JOBID | CLF_RENAME)));
/* Move the extension fields to the desired positions */
if ((crf_wanted & CLF_JOBID) && (rec->cr_flags & CLF_JOBID))
_______________________________________________
lustre-discuss mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-discuss-lustre.org