Well, why not try it yourself?
Code:
#include <stdio.h>
#define TYPE0 0
#define TYPE1 1
typedef int Type;
const char* f(Type t);
const char* f(Type t)
{
if(t==TYPE0)
return "type zero";
if(t==TYPE1)
return "type one";
return "no valid type";
}
const char* v=f(TYPE0);
int main(void)
{
printf("v = <%s>\n",v);
return 0;
}
Produces:
Code:
19: error: initializer element is not constant
Let's move where we declare v:
Code:
#include <stdio.h>
#define TYPE0 0
#define TYPE1 1
typedef int Type;
const char* f(Type t);
const char* f(Type t)
{
if(t==TYPE0)
return "type zero";
if(t==TYPE1)
return "type one";
return "no valid type";
}
int main(void)
{
const char* v=f(TYPE0);
printf("v = <%s>\n",v);
return 0;
}
Output:
Perfect.
As to where string literals are created, they are generally created in read-only memory (although this cannot be guarenteed and therefore read-only memory should be assumed). In segments, this might be the .data segment.