From: Benjamin F. <ben...@he...> - 2011-09-07 18:15:13
|
Am Mittwoch, 7. September 2011, um 19:29:59 schrieb Marty Kraimer: > On 09/07/2011 12:42 PM, jam...@di... wrote: > > The obvious is std::vector<FieldConstPtr> fields(numberNewFields) if > > you can take the hit of heap allocation. I don't have a nice feeling > > about alloca. > > I think that You are marching down a path You will not like. > > Any windows expert have any ideas? Not a windows expert at all, but I had the same problem in the sequencer. After many iterations we arrived at this code: // somewhere near top of file: #ifdef _WIN32 # include <malloc.h> #elif (__STDC_VERSION__ < 199901L) && !defined(__GNUC__) # include <alloca.h> #endif ... // use site epicsShareFunc pvStat caVariable::get( pvType type, unsigned count, pvValue *value ) { int caType = typeToCA( type ); #if (__STDC_VERSION__ >= 199901L) || defined(__GNUC__) char caValue[dbr_size_n( caType, count )]; #else char *caValue = (char*)alloca( dbr_size_n( caType, count ) ); #endif ... } Not nice but, AFAIK, this version compiles and works on all architectures and compilers that EPICS currently supports. Cheers Ben ________________________________ Helmholtz-Zentrum Berlin für Materialien und Energie GmbH Mitglied der Hermann von Helmholtz-Gemeinschaft Deutscher Forschungszentren e.V. Aufsichtsrat: Vorsitzender Prof. Dr. Dr. h.c. mult. Joachim Treusch, stv. Vorsitzende Dr. Beatrix Vierkorn-Rudolph Geschäftsführer: Prof. Dr. Anke Rita Kaysser-Pyzalla, Dr. Ulrich Breuer Sitz Berlin, AG Charlottenburg, 89 HRB 5583 Postadresse: Hahn-Meitner-Platz 1 D-14109 Berlin http://www.helmholtz-berlin.de |