1 (edited by tmarschen 2016-10-18 23:45:19)

Topic: struct tm compiler error of file wolfssl\wolfcrypt\asn.h

Hello Dear,

I was trying to use WolfSSL 3.9.8.

My test code is as below:

{
#include "wolfssl/wolfcrypt/asn.h"
...
#include <time.h> 
...
}

It will get compiler error as below:
.../include_posix/time.h", line 104: Error:  #101: "tm" has already been declared in the current scope
  __USING_NAMESPACE_STD(tm)

As wolfSSL have defined it's own struct of "tm", i think there maybe some conflict between wolfSSL and posix head file.
So I tried to modify wolfssl/wolfcrypt/asn.h which is attached, and the compiler success.

Is my modify OK? Is there any bug in wolfssl?

thanks for your help

Post's attachments

asn.h 27.95 kb, 1 downloads since 2016-10-19 

You don't have the permssions to download the attachments of this post.

Share

Re: struct tm compiler error of file wolfssl\wolfcrypt\asn.h

Hi tmarschen,

So we have a "struct tm" in asn.c that is implemented if defined USE_WOLF_TM.

You've added this check:

#ifndef USE_WOLF_TM
#include <time.h>
#endif

which accomplishes this: "If wolfssl is not going to implement a tm structure then we're going to include the posix time.h header which DOES implement the tm structure" Then we will define wolfssl_tm to be that tm instead of the one in wolfssl/wolfcrypt/src/asn.c (since it wasn't implemented in this case)"

There is nothing wrong with doing that as long as the tm struct in <time.h> has all the same elements and will not result in our library accessing some element of that structure that doesn't exist.

We try to remain as portable as we can across all platforms. I believe you have identified a case where we were not 100% portable. We would not consider this a bug because there is no "undefined" or "unexpected" behavior taking place during the execution of the program. This is a compile time issue that resulted from building on a non-standard environment. Porting and building on different environments often requires minor additions/modifications to get everything working smoothly. When we identify these portability issues we try to account for them for all future users so thank you for pointing it out to us.

Could you tell us the operating system and version you are working on, which compiler you're building with and how your include directories are setup (IE why the ../include_posix/time.h). If we can replicate the issue we can look into getting a fix for portability sake.

Thank you again for your question and we look forward to hearing back from you.


Kind Regards,

Kaleb and the wolfSSL Team