如何在Objective C / XCode中使用cim

How to use CImg in Objective C / XCode?

本文关键字:cim XCode Objective      更新时间:2023-10-16

我知道clang可以将c++文件编译为.mm,但是cml只是一个单独的.h文件。无论我是否将扩展更改为.mm或将其保留为.h,它都不起作用。

首先,它抱怨找不到cstdio.h。因此,我将所有cstd..导入更改为c对应的

// Include standard C++ headers.
// This is the minimal set of required headers to make CImg-based codes compile.
#include <stdio.h> // (was #import <cstdio>)
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <exception.h>

在引入x11库之后,我将导入错误转化为语法错误:

namespace cimg_library_suffixed {

错误:未知类型名称"namespace"

这是因为我把cstdio改成了stdio吗?我困惑. .

答案形式,以备将来参考:

将头文件从obj - c++编译为 #included,头文件将被视为c++代码。