I get this gcc warning with -Wwrite-strings flag. I want to return a string of chars correctly but I also do not want to use malloc. I've read other posts but can somebody explain how to acheive this in layman wording?
a.c:14: warning: passing argument 1 of ‘VAR1’ discards qualifiers from pointer target type
Also, make sure you have enough space to write into.
If he wants the warning...
why would a solution be to silence the warning with the cast?
Depends how you want to look at this....Are you the developer of the app or a developer using the app...i.e. do you have the rights to change the function then yes change it but sometimes(most times) you have to change the data to fit the function...
Who's turning off the warning....I'm coercing the data to fit the function. Its done all the time
Casting is misued a lot of the time. And I would argue that this would be a great example.
If the string itself is nonwritable, the cast silences the warning and passes this nonwritable string to a function that is allowed to write to the string. In this case, the cast might be hiding a bug.
But since the function does not write to the string that is passed, perhaps it would be better to include that in the function signature? That way the compiler doesn't need to play "let's pretend"?
I Developed application in C# with crystal reports and created setup file in third party (Advance) Installer.When i installed my application on client system application is working but ...