添加“使用命名空间..."导致编译错误 [expected '=', ',', ';', 'asm' or...] in xcode 4 [英] Adding "using namespace..." causes compilation error [expected '=', ',', ';', 'asm' or...] in xcode 4

查看:56
本文介绍了添加“使用命名空间..."导致编译错误 [expected '=', ',', ';', 'asm' or...] in xcode 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这很奇怪,每当我将使用命名空间..."添加到头文件时,它就会乱码

This is strange, whenever I add "using namespace ..." to a header file it craps out

 error: expected '=', ',', ';', 'asm' or '__attribute__' before 'namespace'

在我身上.

我删除它,并尝试使用命名空间运算符 ::,就像 cv(对于 OpenCV)它说

I remove it, and try to use namespace operator ::, like cv (for OpenCV) it says

error: expected ')' before '<' token

我的头文件扩展名为 .hpp,实现文件扩展名为 .mm.看起来 xcode 4 正试图将其编译为传统的 C 文件.是吗?

My header file has .hpp extension, and implementation file has .mm. It looks like xcode 4 is trying to compile it as a traditional C file. Is that right?

我该如何解决这个问题?

How do I fix this?

推荐答案

您可以在实用工具 -> 文件检查器面板 (⌘⌥+1) 中更改源文件类型.检查身份和类型"部分.它在那里有文件类型"下拉菜单.在那里检查适当的文件类型,你应该没问题.

You can change your source file type in Utilities -> File Inspector panel (⌘⌥+1). Check "Identity and type" section. It has "File type" drop down there. Check the appropriate file type there and you should be good.

这篇关于添加“使用命名空间..."导致编译错误 [expected '=', ',', ';', 'asm' or...] in xcode 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆