Yeah, that's what I figured.  But I was also under the impression that
const was supposed to ignore that, and I believe static const and const are
supposed to be the same thing.  I did try using static const for one of the
constants, but it still gave me the defined but not used error.  The only
thing I tried that worked was to add __attribute__ ((unused)) (and
M5_VAR_USED that Jason pointed out, but that's the same attribute).

On Fri, Jul 14, 2017 at 4:35 PM, Gabe Black <gabebl...@google.com> wrote:

> The compiler will complain if the constant isn't used somewhere for *any*
> .cc file, not if it isn't used at all, since it only compiles one .cc file
> at a time and wouldn't know that somebody else was using it somewhere. I
> think you can usually address those sorts of problems by making constants
> const and static.
>
> Gabe
>
> On Fri, Jul 14, 2017 at 7:39 AM, Jason Lowe-Power <ja...@lowepower.com>
> wrote:
>
>> Hi Alec,
>>
>> I'm not sure if this really answers your question, but there are a number
>> of places in the code where for different compiler options some variables
>> are unused. This often happens when doing debug checks (e.g., asserts)
>> which are removed when compiling fast mode. To ignore these warnings from
>> the compiler, there is the macro "M5_VAR_USED" which can be used after
>> declaring the variable to make sure that it appears used to the compiler
>> (like __attribute__((unused))).
>>
>> Jason
>>
>> On Thu, Jul 13, 2017 at 3:34 PM Alec Roelke <ar...@virginia.edu> wrote:
>>
>>> Hi Everyone,
>>>
>>> Lately when I've been trying to build gem5.opt for RISC-V, I've been
>>> getting an error that three of the scalar constants defined in registers.hh
>>> are 'defined but not used' (one of which definitely is used in faults.cc).
>>> I've been under the impression that g++ is supposed to ignore this warning
>>> for values defined as const, but I've had to mark them with __attribute__
>>> ((unused)) to get it to compile.
>>>
>>> The only solutions I can find (define them as extern and initialize them
>>> in a .cc file) when I search for it only apply to arrays, but all the const
>>> arrays in registers.hh work fine.  This error only appears for some of the
>>> scalar constants.
>>>
>>> Is anyone else having this issue?
>>>
>>> Thanks,
>>> Alec Roelke
>>> _______________________________________________
>>> gem5-users mailing list
>>> gem5-users@gem5.org
>>> http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
>>
>>
>> _______________________________________________
>> gem5-users mailing list
>> gem5-users@gem5.org
>> http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
>>
>
>
> _______________________________________________
> gem5-users mailing list
> gem5-users@gem5.org
> http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
>
_______________________________________________
gem5-users mailing list
gem5-users@gem5.org
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users

Reply via email to