> > On 24 Aug 2013 at 09:04, [email protected] wrote: > Le 29/08/13 18:59, Steve Jaffe a ?crit : > > Another alternative is simply to declare such a function as "inline." > > I don't think that works and I've had examples to verify this belief. >
I'd be interested in studying those examples if you could provide them. What I'm describing refers to C++. The meaning of 'inline' in C is both different and more complex -- for one thing it differs between the C99 and C89 standards. What I recommended would not necessarily prevent multiple-definition errors if using a C compiler (but then neither would using templates be an option -- therefore I am assuming that this discussion is only about C++) In order to see why it makes sense for C++ to work this way, consider class member functions defined inside the class declaration. These are inline by default, and that is why they do not produce multiple-definition errors although they are defined in every compilation unit which includes the class declaration header file. The existence of 'header-only' libraries in C++ (but not C) is another example. True, most of these use templates (which also are inline by default -- note that 'inline' in the C++ sense serves two related but different purposes -- to 'hint' to the compiler that the code should be inlined, and to *require* the linker to merge multiple definitions.) But the 'inline'-ness of template functions is what makes this work, and one can have a header-only C++ library that uses inline functions without templates. Regards, Steve [email protected] _______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
