Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

By the way, one thing that came up for me last week was that we probably ought to mention conformant array parameters. For example,

int f(size_t n, int a[n])

is a handy way to document the size of an array parameter.

 

Noncompliant Code Example

void my_memset(char* p, size_t n, char v) {
  memset( p, v, n);
}

Noncompliant Code Example

This doesn't compile because n is used before being declared.

void my_memset(char p[n], size_t n, char v) {
  memset( p, v, n);
}

Compliant Solution

void my_memset(size_t n, char p[n], char v) {
  memset( p, v, n);
}

Bibliography

C99, section 6.7.6.3 (see example 4)

  • No labels