[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UDUNITS #QVW-190351]: ut_get_converter and constness of args.

This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.


  • Subject: [UDUNITS #QVW-190351]: ut_get_converter and constness of args.
  • Date: Wed, 05 Aug 2009 13:38:00 -0600

Erik,

> I tried changing the function declaration and definition to take constant
> pointers to constant ut_units and udunits2 compiled fine.

That surprises me because, as I said, the ut_get_converter() function might 
modify the passed-in units.

> I only tried
> compiling with gcc (version 4.3.2 20081105 (Red Hat 4.3.2-7)) though.

Probably indicates a bug in gcc 4.3.2.

> The reason I'm interested in this, is that I've written a C++ wrapper for the
> library, and passing temporaries to reference variables requires constant
> references.  Currently I'm casting away the constantness to call
> ut_get_converter, but I'd like to avoid that if possible.

Sorry, I'm afraid I can't simultaneously help you *and* keep my contract with 
the C programming language.

> Erik
> --
> Erik Zeek                     |  \|/ ____ \|/
> SMTS, Org 5444, MS-1153       |  "@'/ .. \`@"
> Sandia National Laboratories  |  /_| \__/ |_\
> Phone: 505-845-0513           |     \__U_/

Regards,
Steve Emmerson

Ticket Details
===================
Ticket ID: QVW-190351
Department: Support UDUNITS
Priority: Normal
Status: Closed