morfizm (morfizm) wrote,

Implementation in C++ headers

Can you name possible problems of having implementation in headers?

I can see the following:

1. Includes may be wrapped with different pragmas that may affect compilation and make structures incompatible (e.g. different #pragma pack).

2. IDE may not insert int 3s in the right places when debugging - breakpoint may not always fire, even in debug mode with no inlining.

3. If you put method pointers into a list and rely on pointer comparison for business logic (e.g. dedup or removal), this can be screwed up.

I am trying to think if there are any other cases. (Anything with class inheritance/VMT/dynamic casts/type checks? Anything you've debugged that had root cause of having implementation in headers? :))


4. In case of DLL, the code might get to client library instead and cause version problems.

5. Compilation speed! Code in headers will cause slow down.
Tags: in english, polls questions and social games, software development

  • Post a new comment


    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.