Question

I have three .asn files. After these three files are compiled by the asn.1 compiler, each file has a corresponding directory in the output folder. In each folder, there are many C source files that were generated by the asn.1 compiler. There is always a .c file which has the same name as the .asn file (except the extension name, i.e. test.asn and test.c). In this file, some functions are defined; like asn_alloc, asn_free etc.

So, there are three files implementing the asn_alloc and asn_free functions. I'll use all the generated C files in my C project.

The problem is, the asn_alloc function is defined in three places. This is the reason I'm getting the compiler error:

multiple definition of function

How do I deal with this problem? I think that editing the generated source file is not a good idea.

Was it helpful?

Solution

This problem is specific to the ASN.1 Tool you are using. With some ASN.1 Tools (such as the one at http://www.oss.com), you can either include all of the .asn files in the same compilation so that one .c file is generated with all names disambiguated, or you can use the -prefix xxx option on each compilation where xxx is different for each ASN.1 compilation thus causing the generated names to be prefixed with xxx, therefore not conflicting.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top