project-navigation
Personal tools

Author Topic: net.c issue  (Read 2997 times)

oeystein

  • Guest
net.c issue
« on: July 16, 2007, 10:15:55 am »
In net.c the following is declared:
Code: [Select]

const char * stream_peer_name (struct net_stream *s, char *dst, int len)
{
if (!s)
return "(null)";
else if (stream_is_loopback(s))
return "loopback connection";
else {
char buf[s->addrlen];
void *src;


As you can see, there is an attempt to dynamically initialize the size of array buf based on the variable s->addrlen. Is this standard C? It wont compile in VS2005.

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
net.c issue
« Reply #1 on: July 16, 2007, 11:43:42 am »
no, this should not be allowed in c89 or c99 - i will look that up and fix it

Offline Zenerka

  • Sergeant
  • *****
  • Posts: 301
    • View Profile
net.c issue
« Reply #2 on: July 16, 2007, 12:10:02 pm »
IMO C99 allows that.