Branch: Tag:

2005-03-15

2005-03-15 09:58:35 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Moved C++ alignment function to pike_macros.h.
ALIGNOF() should now work for C++.

Rev: src/pike_macros.h:1.39

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: pike_macros.h,v 1.38 2004/11/14 18:03:50 mast Exp $ + || $Id: pike_macros.h,v 1.39 2005/03/15 09:58:35 grubba Exp $   */      #ifndef MACROS_H
22:    PTR_TO_INT(& (((struct str_type *)NULL)->field))   #define BASEOF(ptr, str_type, field) \    ((struct str_type *)((char*)ptr - OFFSETOF(str_type, field))) + #ifdef __cplusplus + extern "C++" { +  template<typename T> static inline int low_alignof_(T *ignored) +  { +  struct { char x; T y;} *bar = NULL; +  return PTR_TO_INT(&bar->y); +  } + }; + #define ALIGNOF(X) low_alignof_((X*)NULL) + #else   #define ALIGNOF(X) OFFSETOF({ char ignored_; X fooo_;}, fooo_) -  + #endif   /* #define ALIGNOF(X) PTR_TO_INT(&(((struct { char ignored_ ; X fooo_; } *)NULL)->fooo_)) */      #define NELEM(a) (sizeof (a) / sizeof ((a)[0]))