hello everyone and thank you for your help in advance! I consider myself a beginner in C++ as I have manly programmed in C. I am developing a library for a processor which has 6 USART ports. I have a re-defined printf to get messages on the screen from the processor via the serial port. it works but this is what I have in the printf.c source code
each USART is a structure. my question is: is there a way to have a single variable to service them all and not having to comment/uncomment lines each time? something like ...
I an not familiar with using the pre-processor directives however in c++ I dont think it is needed in this instance. Does this not just replace all instances of USARTx as USART1?
Could be my inexperience but why not just declare them and make a function that returns whichever you need? Or if there is some reason you must use the pre-processor, you can make a define function macro that defines it differently based on conditions.
hi pata and thank you for your reply! The idea is to have USARTx identifying the USART I am using but I can't figure out how to tell that to this function as I cannot have that as a function parameter. I have such constant in the USART library