Preprocess constants.

Paul Faure paul@engsoc.org
Fri Jun 29 12:08:00 GMT 2001


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



More information about the Gcc-help mailing list