Can I force a compiler error if certain functions are called?

前端 未结 6 917
花落未央
花落未央 2021-01-11 13:19

I have v1 and v2 versions of my software. v1 uses the registry to save settings, with lots of calls to GetProfileInt, etc. v2 now uses an sqlite db to save settings.

<
6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-11 14:03

    If you have an #include file that is common, you could add something like this to it (with the W or A as appropriate). It would result in, at least, a linker error (compiler warning/error would depend on the flags):

    #define GetProfileIntA InvalidFunctionDoNotCallMe
    

    Windows already defines the functions such as GetProfileInt as macros to the A or W versions.

提交回复
热议问题