This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Preprocess constants.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]