Posts

Showing posts with the label lifetime

check string lifetime duration

check string lifetime duration I am currently wondering if it is possible to check if a C-string has a static lifetime duration or not when only the pointer to the string is known. Basically, I want to implement such a function: bool isStaticString(const char *str) { //do magic stuff } and the results should be like this: isStaticString("Hello World!"); //returns true char str[5] = {''}; isStaticString(str); //returns false Is there any portable way to implement such a function? PS: I hope such question was not already asked,I did not really know what to search for. My title did not give me any results. No, and why do you need this? – UnholySheep Jun 30 at 20:19 Are you asking about C or C++? – melpomene Jun 30 at 20:22 ...