Haoest
Haoest

Reputation: 13916

Adding "using namespace..." causes compilation error [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'

on me.

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

error: expected ')' before '<' token

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?

Upvotes: 1

Views: 4644

Answers (1)

Eimantas
Eimantas

Reputation: 49354

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.

Upvotes: 2

Related Questions