<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Sam,<div class=""><br class=""></div><div class="">thanks for rapid responding. Yes, you’re right. I’ve forgotten to provide some descriptive code.</div><div class=""><br class=""></div><div class="">I’ve issued the constant-string-class flag in both files: compile_flags.txt at first and than in compile_commands.json to no avail.</div><div class=""><br class=""></div><div class="">NGStringLiteral is declared exactly like NXConstantString and demanded in the LLVM documentation, i.e. Class, char*, and unsigned int. Like so:</div><div class=""><div class=""><br class=""></div><div class=""><font face="Courier" class="">@interface NGStaticObject</font></div><div class=""><font face="Courier" class="">{</font></div><div class=""><font face="Courier" class="">  Class isa; /* A pointer to the instance's class structure.  */</font></div><div class=""><font face="Courier" class="">}</font></div><div class=""><font face="Courier" class="">...</font></div><div class=""><font face="Courier" class="">@end</font></div></div><div class=""><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">@interface NGStringLiteral : NGStaticObject</font></div><div class=""><font face="Courier" class="">{</font></div><div class=""><font face="Courier" class="">  char *c_string;</font></div><div class=""><font face="Courier" class="">  unsigned int len;</font></div><div class=""><font face="Courier" class="">}</font></div><div class=""><font face="Courier" class="">@end</font></div></div><div class=""><br class=""></div><div class="">The test code in question is:</div><div class=""><br class=""></div><div class=""><font face="Courier" class="">NGStringLiteral *test0 = @"Hello world”;<span class="Apple-tab-span" style="white-space:pre">    </span>// —> “Incompatible pointer types initializing 'NGStringLiteral *' with an expression of type 'NSString *’”</font></div><div class=""><br class=""></div><div class="">A first attempt to mitigate this was:</div><div class=""><br class=""></div><div class=""><font face="Courier" class="">typedef NGStringLiteral NSString;</font></div><div class=""><div class=""><font face="Courier" class="">NSString *test1 = @"That's me;)”;<span class="Apple-tab-span" style="white-space:pre">       </span>// —> “Incompatible pointer types initializing 'NSString *' (aka 'NGStringLiteral *') with an expression of type 'NSString *’”</font></div><div class=""><br class=""></div><div class="">Another attempt is subclassing NSString from NGStringLiteral. This quiets clangd, but now the compiler (gcc) complains “warning: initialization from distinct Objective-C type”. But this is another story.</div><div class=""><br class=""></div><div class="">All the above code would be irrelevant if clangd would regard the constant-string-class flag.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class=""><br class=""></div><div class="">Andreas</div><div><br class=""><blockquote type="cite" class=""><div class="">On 3. Jul 2019, at 21:08, Sam McCall <<a href="mailto:sammccall@google.com" class="">sammccall@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="auto" class=""><div class="">Hi Andreas,</div><div dir="auto" class=""><br class=""><div dir="auto" class="">Can you provide a minimal source file that exhibits the problem, and explain how you're specifying the -fconstant-string-class flag? (It should be in the compile_commands.json or compile_flags.txt file)</div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">It sounds like what you're describing should work, but I think we need more detail to reproduce the issue.</div><div dir="auto" class=""><br class=""></div><div dir="auto" class=""> I cant really speak to the layering between objc the language and the Foundation etc libraries. I'm sympathetic to the frustration but realistically clangd won't diverge from clang here, so this would be an issue for experts on cfe-dev.</div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">Cheers, Sam</div><br class=""><br class=""><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Wed, Jul 3, 2019, 7:57 PM Andreas Ostermeyer via clangd-dev <<a href="mailto:clangd-dev@lists.llvm.org" class="">clangd-dev@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">clangd developers,<br class="">
<br class="">
currently I’m working on an own small footprint Objective-C Class library completely unrelated to Cocoa. I use clangd [version 8.0.0 (tags/RELEASE_800/final)] from homebrew as the language server in my IDE.<br class="">
<br class="">
Unfortunately I can’t clangd persuade to accept my own as a constant string class with the flag "-fconstant-string-class=NGStringLiteral". Ignoring the flag it complains: “Incompatible pointer types initializing 'NGStringLiteral *' with an expression of type 'NSString *’”.<br class="">
<br class="">
To quiet this I declared ’NSString’ as ’NGStringLiteral’ (“typedef NSString NGStringLiteral”). Now clangd warns: “Incompatible pointer types initializing 'NSString *' (aka 'NGStringLiteral *') with an expression of type 'NSString *’”!<br class="">
<br class="">
That’s annoying - like all the hard-wired Cocoa aka Apple stuff in clang software. Objective-C is an independent general purpose programming language. Not a Cocoa development tool and not an Apple software product. This should be true for clang, too.<br class="">
<br class="">
So, what can I do (or what can you do) to get rid of - at least - this?<br class="">
<br class="">
Thanks in advance.<br class="">
<br class="">
Best regards,<br class="">
<br class="">
Andreas Ostermeyer<br class="">
_______________________________________________<br class="">
clangd-dev mailing list<br class="">
<a href="mailto:clangd-dev@lists.llvm.org" target="_blank" rel="noreferrer" class="">clangd-dev@lists.llvm.org</a><br class="">
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev" rel="noreferrer noreferrer" target="_blank" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev</a><br class="">
</blockquote></div></div></div>
</div></blockquote></div><br class=""></div></body></html>