extern "C" {
    fn abs(x: i32) -> i32;
}
fn main(){
    unsafe {
        println!("{}", abs(-123));
    }
}
sub.h
#ifndef SUB_H #define SUB_H extern int gNumber; #endif
sub.c
int gNumber = 100;
void func(void){
    gNumber += 100;
}
main.c
#include <stdio.h>
#include "sub.h"
int main(void) {
    func();
    printf("gNumber: %d\n", gNumber);
}
$ g++ -o test test.cpp sub.cpp  && ./test
test.cpp: In function ‘int main()’:
test.cpp:5:5: error: ‘func’ was not declared in this scope
    5 |     func();
うーん、これはエラーになっちゃうな…
 
					 
