Maximum length of class name in objective-c

What is the maximum length of a class name in objective-c

? I couldn't find any hints in the xcode docsets and google didn't help either.

I am currently writing some runtime helpers and it would be nice to know if my char buffers are good enough to encode the types.

+3


source to share


2 answers


Since Objective C is not a standardized programming language, this question cannot be answered. But it rather depends on what your compiler supports. I think the main Objective C compilers (Clang / LLVM, GCC) support all lengths of class names. To find out what you need to look at their sources. But since they are both written in C ++, they will probably use std: string and therefore be length independent.

I tried and tried to compile a project with a class name of 100,000 characters using clang / llvm in Xcode, which worked fine.



So your buffers probably won't be big enough.

+2


source


I don't believe there is a limit on the size of the class name, why not?

When Obj-C is run on top of C, it will follow their standards. Identifiers in C do not have a maximum length as stated in the question " Maximum identifier length "



It is highly unlikely that you will come across a class name longer than 100 characters, but you can always have more buffers to be safer.

+2


source







All Articles