Отмечание библиотечных функций как устаревшие/неприменимые, не изменяя их исходный код

Каковы точно ошибки и функциональность, которую Вы пропускаете?

От сканирования по Вашему документу, кажется смешиванием синтаксиса и семантики. Я не понимаю, почему различать SimpleTypeFloat и SimpleTypeOrdinal на синтаксическом уровне или приоритет оператора кода, поскольку синтаксическая функция в AddOp и MulOp. верный, ложный, ноль является идентификаторами так же, как любым именем переменной, Вы выбираете.

9
задан Ciro Santilli 新疆改造中心法轮功六四事件 11 August 2015 в 14:15
поделиться

2 ответа

Create a custom header deprecated.h. In there, create your own wrapper functions, deprecated_strtok() etcetera that merely call strtok. Mark those with __attribute__((deprecated)). Below those definitions, #define strtok deprecated_strtok. Finally, use -include deprecated.h

12
ответ дан 4 December 2019 в 11:06
поделиться

Try this in a source file, with a gcc enough recent it should avoid developers using these both functions.

#pragma GCC poison gmtime
#pragma GCC poison strtok

The downside of it is that it is only valid for one compilation unit. If you use precompiled headers (which you surely do if your project is big), you could put them there. At least this solution does not involve decorating function declarations in system headers and works at compile time.

Poison is maybe a bit hard as it produces errors and not warnings. Does anyone know how to weaken it? At least it is a nice way to enforce a DO NOT USE FUNCTION xxx policy.

7
ответ дан 4 December 2019 в 11:06
поделиться