> From: [email protected] [mailto:owner-openssl-
> [email protected]] On Behalf Of Iñaki Baz Castillo
> Sent: Tuesday, 09 September, 2014 12:44
> To: [email protected]
> Subject: Re: Why does OpenSSL own all the prefixes in the world?
>
> May be I was not clear, but what I mean is:
>
>
> - Let's suppose openssl/foo.h has a #include <stdlib.h>.
>
> - In myproject.h I add:
>
> namespace myproject {
> #include <openssl/foo.h>
> }
>
> - And then in myproject.cpp I write:
>
> p = (char*)malloc(sizeof(char) * 100);
>
>
> Would this produce the "malloc not found, may be you mean
> 'myproject::malloc'?" error?
>
> PS: Note that I do NOT include <sdtlib.h> in myproject.*.
Yes, in this case I'd expect that error. You need to include stdlib.h outside
of any namespace before you include openssl/foo.h.
My advice would be to stick a bunch of include statements for all the standard
headers used by any openssl/*.h into a single .h file, and then include that at
the top of myproject.h and any other C++ header file that includes an OpenSSL
header.
So:
- Create openssl_c_hdrs.h which has:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
...
- Change myproject.h to have:
#include "openssl_c_hdrs.h"
namespace myproject {
#include <openssl/foo.h>
}
Again, I can't say for sure that will work, because I haven't tested it. But it
ought to work around this particular issue. The standard headers included by
openssl_c_hdrs.h will preempt their inclusion within the namespace by the
OpenSSL headers.
Of course, for C++ code you normally wouldn't include the C standard headers;
you'd use their C++ versions (<cstdlib>, etc). But this sort of thing is a
special case.
--
Michael Wojcik
Technology Specialist, Micro Focus
This message has been scanned for malware by Websense. www.websense.com