Skip to content

error: 'mpi.h' file not found [clang-diagnostic-error] #121212

@pierre-24

Description

@pierre-24

While running clang-tidy, using clang-tidy -checks=* openmpi_test.cpp , on the file given below, I get (among other things) error: 'mpi.h' file not found [clang-diagnostic-error]:

#include <mpi.h>
#include <cstdio>

void print_processors() {

    // Initialize the MPI environment
    MPI_Init(nullptr, nullptr);

    // Get the number of processes
    int world_size;
    MPI_Comm_size(MPI_COMM_WORLD, &world_size);

    // Get the rank of the process
    int world_rank;
    MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);

    // Get the name of the processor
    char processor_name[MPI_MAX_PROCESSOR_NAME];
    int name_len;
    MPI_Get_processor_name(processor_name, &name_len);

    // Print off a hello world message
    printf("Hello world from processor %s, rank %d out of %d processors\n",
    processor_name, world_rank, world_size);

    // Finalize the MPI environment.
    MPI_Finalize();
}

However, while using mpicxx main.cpp openmpi_test.cpp -o test (main.cpp only calls print_processors()), everything goes well. Thus, this is not supposed to be reported :)

Furthermore, it is not possible to supress this "error" with NOLINT.

Tested with:

  • Clang-tidy v19.1.5 on Fedora 41, with OpenMPI,
  • Clang-tidy v19.1.6 on Ubuntu 22.04 (Github runner) with OpenMPI/Intel MPI (installed using this action).

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions