Wednesday, July 06, 2016

migrating C functions when code refactoring

functions are default extern, so you don't need the extern on them when you move the declaration to a header file and definitions to a new file.

when adding the functions to the new cpp file, move the full function over, put the declaration in the header, include the header in the old file you are migrating from but still intend to reference the function. include the new header in the old function.

for the new .cpp file with the code that has migrated from the old .cpp to the new .cpp, include the new header file.

include the .cpp file for the new code in the project as well. or just wait until visual studio complains you forgot this step, come here to re-read this blog post, then do it :)

TODO: add an example here for clarity, but not tonight :)

No comments: