Search code examples
autocompletewarningsvim-pluginclangdvim-ale

How to hide the specific warning hint from vim plug ALE supported by clangd in cpp file?


Problem Details:

I download the clangd for vim plug ALU to support the cpp syntax autocompletion, but in C++ code, there is a warning message that always appears as below:

'new' of type 'Vmux41' with extended alignment 64 [-Waligned-new=]

below is my whole C++ code of testbench file of mux digital circuit:

#include "verilated.h"
#include "verilated_vcd_c.h"
#include "../obj_dir/Vmux41.h"

VerilatedContext* contextp = NULL;
VerilatedVcdC* m_trace = NULL;

static Vmux41* dut;

void step_and_dump_wave(){
    dut->eval();
    contextp->timeInc(1);
    m_trace->dump(contextp->time());
}
void sim_init(){
    contextp = new VerilatedContext;
    m_trace = new VerilatedVcdC;
    dut = new Vmux41;               // <-- warning happens here
    contextp->traceEverOn(true);
    dut->trace(m_trace, 0);
    m_trace->open("waves/waveform_mux41.vcd");
}
void sim_exit(){
    step_and_dump_wave();
    m_trace->close();
}

int main() {
    sim_init();

        ...

    sim_exit();
}

In function sim_init, the statement dut = new Vmux41; will get above warning info, I search some questions as well as asking poe AI. The final answer is that the current platform(Ubuntu 22.04) does not support this alignment requirement.

Finally, I confirm this is associated to my specific platform. So I needn't solve it but only hide it.

Expecting:

Is there any method to hide this specific warning info in vim. (actually the warning side bar make me upset)


Solution

  • ALE runs several code checkers (aka linters) under the hood. It is turned off very much like you would turn it off when running the individual linters from command line.

    In your case GCC's -Waligned-new seems to be the culprit and it can be turned off by passing -Wno-aligned-new.

    The line to add to your vimrc is accordingly:

    let g:ale_cpp_cc_options = '-Wno-aligned-new'
    

    To suppress this one warning when linting with GCC.