The custom type in dll contains non-exported public fields, resulting in an exception in running the release version.

Source: Internet
Author: User

Yesterday I tried to release my custom dll version to release. There is a console in my project.ProgramThe program references two custom DLL files. The program runs normally in debug mode, but an exception occurs immediately after it is released to the release version.

This type of problem is very common, so I also searched the internet for a lot of differences between the debug version and the release version. However, the problem cannot be solved after multiple attempts, finally, I tried to eliminate all compilation warnings to see if the problem could be solved. Which of the following is the most frequently seen in my warnings:

 

Warning 1 warning c00001: 'zacharyhash: bucketnode: _ value': Class 'std: basic_string <_ ELEM, _ traits, _ ax> 'needs to have DLL-interface to be used by clients of class 'zacharyhash: bucketnode' E: \ C & C ++ study projects \ algorithms \ hash \ hashlib \ bucketnode. h 27 1 hashlib

 

This warning comes from this custom type:

   code highlighting produced by actipro codehighlighter (freeware) 
http://www.CodeHighlighter.com/
--> class hashlib_api bucketnode
{< br> Public :< br> bucketnode ( void );
~ bucketnode ( void );
string _ value;
bucketnode * _next;
};

This class is an internal type used by the chain address hash table, so I didn't set getter and setter for its fields, because it seems inefficient, directly column its data as a public field. However, due to temporary negligence, this type is also defined as the DLL output type (hashlib_api), so the compiler prompts that if you want to use this type as the DLL output, the types involved in its public members should also be declared as DLL output (here it is the string type), otherwise it will cause an error. So why is this message a warning message instead of a compilation error? The reason may be that the person who references the DLL outside may not necessarily use this public member (that is, _ value), but it must be referenced, and an exception will occur.

However, I have two questions that have not been resolved.ArticleCan you give me some advice.First: Why do the standard library type such as string type need to be manually declared as the DLL export type? How do I declare a statement? Second: Why does this error not reference the program running in debug mode?

Finally, after I removed all DLL output identifiers, I re-compiled them and replaced them with the newly generated DLL back to the original DLL. In the release version, the program can run normally.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.