0

I've got a strange error working with Photoshop connection API in OSx. I need to include the header of a cpp file to my project... I start from the adobe example and I included the code in this way:

#include "PSCryptor.h" 

which contains the PSCryptor class :

class PSCryptor
{
    public:
...

As soon as i try to use PSCrypor object, like with this code

static PSCryptor *sPSCryptor = NULL;

I get this error:

Unknown type name 'class'; did you mean 'Class'?

Could you help me to understand which is my error?

1 Answer 1

2

The file is being included in Objective-C files — that is, they have the extension ".m" or they are specifically configured to be compiled as Objective-C (probably the former). Thus, the compiler tries to interpret the code as Objective-C, but C++ is not valid Objective-C, so it complains.

What you need to do is use Objective-C++ instead. Simple fix: change the extension of the files that use that header from ".m" to ".mm".

Sign up to request clarification or add additional context in comments.

3 Comments

the example used by Adobe works with a .cpp file, in your opinion how is this possible ?
@MatterGoal: .cpp files are also compiled as C++, so that wouldn't be a problem. It sounds like the trouble you're having is that you're importing this header in a file that is not C++.
@Chunk you're right! i can modify the extension with .mm or modify "file type" property in "identity and Type" box.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.