For compatibility the following options are applied automatically:
-fskeletons-copy
option is given toasn1c
command when it is available (when it is found in the output from the-help
option)Ws2_32.dll
library is added to the list of dependency libraries whenasn1c
version is below 0.9.29 on Windows. In this cases the library is needed to provide the implementation for the POSIXntohl()
function, that may be used by the generated C sources (inconstr_SET.c
).
The following .cmake patch scripts are made available with ASN1.cmake
module. They are not applied automatically (TODO: add checks for auto-apply), but you should probably include them all as arguments to the apropriate keyword (APPLY_DIRECTORY_PATCH_SCRIPT
or APPLY_SOURCE_PATCH_SCRIPT
) when using asn1_add_module_library()
.
All of them were needed in the case of using:
- Windows with Visual Studio
- the default version of
asn1c
provided by the Windows installer (that is 0.9.21, if you do not compileasn1c
from sources with MinGW/cygwin) - the use case of procesing ASN.1 modules for X.509 certificates (DER encoding).
It is possible you will need other patches for your modules or for other compilers.
The included patch scripts are:
- Asn1c_Patch_SkeletonFiles.cmake (directory, internal)
- Used internally by ASN1C.cmake to implement the
COPY_SKELETON_FILE
keyword. It is an example of a directory patch script applied to the working directory afterasn1c
has generated the C sources.
- Used internally by ASN1C.cmake to implement the
- Asn1c_Patch_DuplicateHeaderTimeH.cmake (directory, source)
- Fixes for generated "Time.h" file, which on case-insensitive file systems has the name of the standard C / POSIX runtime header
<time.h>
. The script will rename the generated file to "ASN1_Time.h", and update all the#include
lines in the other sources appropriately. Note that for Linux the file system is tipically case-sensitive so the patch script need not be applied.
- Fixes for generated "Time.h" file, which on case-insensitive file systems has the name of the standard C / POSIX runtime header
- Asn1c_Patch_DuplicateIntTypesTypedef.cmake (source)
- Fixes typedef declarations that duplicate standard C int types int8_t, uint8_t, int16_t, ... declared in
<stdint.h>
. The script will remove the typedefs and add an#include
line for the standard library header instead.
- Fixes typedef declarations that duplicate standard C int types int8_t, uint8_t, int16_t, ... declared in
- Asn1c_Patch_WarningPragma.cmake (source)
- Fixes C preprocessor
#warning "output message..."
lines, and replaces them with lines of the form#pragma message("oputput message...")
. This is becase Visual Studio on Windows does not support the first form.
- Fixes C preprocessor
- Asn1c_Patch_GMTOffsetMacro.cmake (source)
- Fixes macro
GMTOFF(tm)
inGeneralizedTime.c
source (if present), as taking the GMT offset of a calendar date instruct tm
is not yet implemented in Visual C++. Instead this offset is implemented as the difference betweenmktime(&tm)
andgmtime(&tm)
, adjusted for any changes in daylight saving time introduced on the giventm
argument by the call togmtime()
.
- Fixes macro
- Asn1c_Patch_GeneralizedTimeIncludes.cmake (source)
- Fixes missing
#include <stdlib.h>
in GeneralizedTime.c forgetenv()
function. Replaces calls tosetenv()
andunsetenv()
with inlinedo { } while()
blocks that implment the same calls usingputenv()
instead. This is becausesetenv()
andunsetenv()
are not implemented in Visual C++.
- Fixes missing
- Asn1c_Patch_EqualityToAssignSetConstr.cmake (source)
- Fixes an assignament in
constr_SET_Of.c
mistakenly written using==
instead of=
.
- Fixes an assignament in
- Asn1c_Patch_AttributeUnused.cmake (source)
- Removes occurrences of
__attribute__ ((unused))
in the generated sources, as the attribute is not supported in Visual C++.
- Removes occurrences of
- TODO: Asn1c_Patch_ExtendGeneralizedTime.cmake (directory)
- Add equivalents for the standard library date/time functions for working with year ranges above year 3000. Used for ASN.1 GeneralizedTime type.
Note the resulting GeneralizedTime.c file (if you generate it) is still limited by the C run-time library functions from Visual C++ used for date/time maninpulations declared in <time.h>
system header. Microsoft C run-time library limits the year number for date/times to a maximum value of 3000 for x64 system (and 2038 as expected for x86 systems). So if your encoded data uses larger values, the generated code of the modules library will return an encoding error (TODO: Complete the .cmake patch script for supporting extended range of years).