I would like to interface with a C library I've written from a C++ program. The C library is written using modern C, and has made use of the static array specifier to show the minimum length of an array, or that a pointer cannot be NULL.
When I try to write a program that interfaces with an extern "C" function using this feature I get the following message:
error: static array size is a C99 feature, not permitted in C++
Is it not possible to interface with this C library? Will I have to modify the C library, or is there an alternative available?
Here's an example program that causes the error:
// foo.h
#ifndef FOO_H
#define FOO_H
void foo(int i[static 1]);
#endif //FOO_H
// foo.c
#include <stdio.h>
void foo(int i[static 1]) {
printf("%i", i[0]);
}
// main.cpp
extern "C"
{
void foo(int i[static 1]);
}
int main() {
int i[] = {1};
foo(i);
}