slycelote / caide

Automates certain common tasks that you do during programming competitions
84 stars 18 forks source link

duplicates of typedef and macros #17

Closed ghost closed 5 years ago

ghost commented 6 years ago

(duplicates) including more than one custom library with some macroses and typedefs (some may exist in more than one library) leads to appearing of duplicates of macroses and typedefs.

and also all macroses and typedefs aren't grouped together and separated by functions.

i suggest to group all macroses together and remove duplicates and then write them in submission file. and the same for typedefs.

slycelote commented 6 years ago

Current implementation works in the assumption that all cpp files concatenated together form a valid program. This is highly unlikely to change, unless there's a very good reason.

Note that blindly combining different sets of files ("sublibraries") together can't generally work anyway. (What if one sublibrary defines using foo=int and another using foo=float?) There are simple workarounds, e.g. putting sublibraries into different namespaces or resolving duplicates/conflicts manually (this would mean extracting typedefs/macros into a common header and including it from both sublibraries).

Regarding the second point, this is not the case that all definitions should be grouped together. Some typedefs/macros may be specific to a small set of functions, and they should be defined close to their usage. If you want some definitions to always be on top, put them into a header and include it as the first header in the solution file.