I work on a large project where many functions are not used. I would like to be able to tag some of them as required, and have ld issue an error if it’s not used in the project it’s linking.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
@Raghuram
That option is to make sure unused code isn’t stripped off.
There is no option to force usage of a function.
For a static function (not exposed), so called dead-code, the function may be optimized out during linkage – which your option will prevent.
For exposed functions, these normally aren’t stripped since it could at a later point be referenced.
@victor
There is no option to force this, you need to define your own guard within other functions to make sure your ‘needed’ function are called upon first.