<div dir="ltr">Hello,<div><br></div><div>I have a question about a code composition. I want to implement a macro computing maximal</div><div>amount of hexadecimal digits one can use to house an integer. (I would've been fine with just</div><div>using a constant but my team prefers a more generic approach to this matter.)</div><div><br></div><div>The thing is, I don't know where I should put this macro for it to make most sense. I see these</div><div>possibilities but am not sure what is the 'best one' regarding a good cstyle.</div><div><br></div><div><ul><li>lib/printk.h - since this computation is used for printing integers, it would make sense<br>to put it here, but my teammate pointed out that then the macro would be available from<br>everywhere lib/printk.h is included (which will be probably everywhere)</li><li>printk.c - I could put it directly in the .c file since is supposed to be used only in it, but<br>it seems awkward to me put macro in .c file</li><li>lib/utils.h - standalone header file for any constants, macros and stuff we might want to<br>implement (this seem like a good approach to me personally), but it comes with<br>the same problem as first point does, every macro / util would be visible in files that<br>are not meant to use it or see it<br>  Â  e.g. ```#define LOWER_CASE 'a' - 10 ``` which is a constant used for printing<br>  Â  hexadecimal literals 'shouldn't' be visible to a heap operating code, should it?</li></ul></div><div><div>Perhaps I am chasing a ghost thinking like this (I would say object-oriented?) in a language</div><div>like C is. On the other hand, in a review of my code, it was recommended to me using a `static`</div><div>modifier for functions only used for printing (e.g. print_string, print_pointer, etc.) so the</div><div>question might not be completely off.</div><div><br></div>Best regards,<br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Sebastian Uhlík<div>========================================================================</div></div></div></div></div>