This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Preprocess constants.
- To: <gcc-help at gcc dot gnu dot org>
- Subject: Preprocess constants.
- From: Paul Faure <paul at engsoc dot org>
- Date: Fri, 29 Jun 2001 15:07:54 -0400 (EDT)
- Organisation: Engsoc Project (www.engsoc.org)
Why will this code not compile ? Can GCC not figure out the strlen() of a
constant string at preprocess time ?
#include <stdio.h>
#include <string.h>
#define IP_SIZE ((const int)(strlen((const char *)"255.255.255.255")+1))
char ip[IP_SIZE];
int main(){
printf("Size of IP->%d\n",IP_SIZE);
strcpy(ip, "192.168.0.3");
printf("IP=%s\n",ip);
return 0;
}
The error that I get is "variable-size type declared outside of any
function".
Thank you.
I am not on the list, so please include my e-mail in the reply.
--
Paul N. Faure 613.266.3286
Chief Technical Officer, CertainKey Inc. paul@certainkey.com
Carleton University Systems Eng. 4th Year paul@faure.ca
Engineering Society Administrator paul@engsoc.org