<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/89323>89323</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
NSString Warning Not Needed
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
RuiCuco
</td>
</tr>
</table>
<pre>
I'm doing my own string class in Objective-C called 'kString'. If I compile the project with the compiler option '-fconstant-string-class=kString', I get the following warning:
```
test.m:43:11: warning: incompatible pointer types initializing 'kString *' with an expression of type 'NSString *' [-Wincompatible-pointer-types]
43 | kString *k = @"Hello!\n";
| ^ ~~~~~~~~~~~
```
clang shouldn't issue any warning because it works everytime I use the @"" literal. The pointer types are not incompatible: I tested it and it simply works! No warning needed!
By the way, how about implementing a similar mechanism for the other @ literals? I could say, for example:
```
@interface kObject
{
Class isa;
}
@end
@interface kInt : kObject
{
int i;
}
@end
@interface kFloat : kObject
{
float f;
}
@end
int main(void)
{
kInt *myInt = @42;
kFloat *myFloat = @3.14f;
return 0;
}
```
and then compile with the compiler options '-fconstant-int-class=kInt' and '-fconstant-float-class=kFloat' to generate the correct code. Why am I asking you to go to all this trouble? Because it's coherent with the string mechanism mentioned above and because the Objective-C language should't expect anything from its libraries, no class names and no method names, as much as possible. That is, only the structure of data is important, like a string object being expected to have a 'Class isa', a 'char* cString', and an 'unsigned int length'. The rest should be at the programmer's discretion. It's good design, I think.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVk3PozYQ_jXOZZQIDFmSQw55k0bN5a3UrbTnASbgxtiRbd4sPfS3V2PI13a3HygCgWee-X4m6L1qDNFGLN_Ecj_DPrTWbX7t1a6v7Ky09bA5Cll0UFtlGugGsFcDPjh-qzR6D8rAL-XvVAX1QfMdVKg11SBkcf4cxYQsFnA8wREq212UJggtwcVZ1oGrCm38MB06sJegrGGA-amyxgc0YT5anEeLIts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