I'm trying to compile a MSMPI program in C with gcc.
Here is what I am including in my code:
#define MSMPI_NO_SAL
#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
I'm using Vscode with the following task:
{
"version": "2.0.0",
"tasks": [{
"type": "shell",
"label": "C/C++: gcc.exe build active file",
"command": "C:\\MinGW\\bin\\gcc.exe",
"args": ["-g", "${file}","-I","C:\\Program Files (x86)\\Microsoft SDKs\\MPI\\Lib\\x64","-I","C:\\Program Files (x86)\\Microsoft SDKs\\MPI\\Include", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe"],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
}
}]
}
However, when trying to compile, I get the following error for my code:
In file included from d:\Documents\1.Ecole\University\Undergrad\Fall 2020\COMP 428\ass1\pi_est_parallel.c:5:
C:\Program Files (x86)\Microsoft SDKs\MPI\Include/mpi.h:4617:5: error: unknown type name '_Out_writes_'; did you mean '_mpi_writes_'?
4617 | _Out_writes_(maxprocs) int array_of_errcodes[]
| ^~~~~~~~~~~~
| _mpi_writes_
C:\Program Files (x86)\Microsoft SDKs\MPI\Include/mpi.h:4629:5: error: unknown type name '_Out_writes_'; did you mean '_mpi_writes_'?
4629 | _Out_writes_(maxprocs) int array_of_errcodes[]
| ^~~~~~~~~~~~
| _mpi_writes_
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command C:\MinGW\bin\gcc.exe -g 'd:\Documents\1.Ecole\University\Undergrad\Fall 2020\COMP 428\ass1\pi_est_parallel.c' -I 'C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x64' -I 'C:\Program Files (x86)\Microsoft SDKs\MPI\Include' -o 'd:\Documents\1.Ecole\University\Undergrad\Fall 2020\COMP 428\ass1\pi_est_parallel.exe'" terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
Am I forgetting to include something when compiling?
This is a known issue in the Microsoft mpi.h
header file:
The issue references a simple patch adding _Out_writes_
to fix this. You can mirror this in your own code by adding
#define _Out_writes_(x)
before you include mpi.h
if you cannot upgrade to the latest version.