Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

From: Brian Barrett (brbarret_at_[hidden])
Date: 2006-09-17 20:31:09


I ran into a situation (I don't remember the exact details,
unfortunately), where the C compiler supports asprintf() but the C++
compiler doesn't. I believe this came up when I was compiling with
gcc (C) and xlC (C++). But it might have been another set of
compilers -- I unfortunately don't have the notes on the issue with
me right now.

I think the simple solution is to not use asprintf in C++
applications and avoid the issue of C/C++ incompatibilities.

Brian

On Sep 12, 2006, at 7:20 AM, Jeff Squyres wrote:

> We actually have a portable version of asprintf() in the OMPI code
> base. On
> platforms that don't support asprintf(), the configure magically
> swaps in
> the OMPI equivalent.
>
> See opal/util/printf.c.
>
>
> On 9/12/06 6:07 AM, "Christian Siebert"
> <christian.siebert_at_[hidden]> wrote:
>
>> Hi again,
>>
>> there is a tiny portability problem located in ompi/tools/
>> ompi_info/param.cc.
>> This code uses the asprintf() function, which is a GNU extension and
>> therefore not very portable. Fortunately, it is not hard to exchange
>> the line
>>
>> asprintf(&value_string, "%d", value_int);
>>
>> with a separate buffer allocation and the ANSI C function sprintf()
>> (although I'd prefer a pre-allocated buffer). Tip: an integer
>> (whether
>> signed or unsigned) has at most ceil(sizeof(int)*2.41) decimal digits
>> (don't forget the trailing null byte!).
>>
>> Christian
>>
>> PS: Thanks Jeff for filing the last bug I've mailed.
>>
>>
>> _______________________________________________
>> devel mailing list
>> devel_at_[hidden]
>> http://www.open-mpi.org/mailman/listinfo.cgi/devel
>
>
> --
> Jeff Squyres
> Server Virtualization Business Unit
> Cisco Systems
> _______________________________________________
> devel mailing list
> devel_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/devel