How to make a program to use diferents visual output?

I want to prepare a project which can build when you choose where to be displayed. (GLCD, LCD 2x16,LCD 4x16 SERIAL), some examples?
You must use # ifdef?

I am not sure I understand your question, but if you are looking at coding an application for different displays that are selectable a switch (the code type) will work.

I would like the binary code that is not enlarged. The problem with making a switch (code) is that I load all the libraries. The idea was unsar the "C_preprocessor" but not whether it is possible to use it.

But you'll have to compile a different version of the sketch for each display type - the pre-processor is not a free lunch.

AWOL:
But you'll have to compile a different version of the sketch for each display type - the pre-processor is not a free lunch.

I know. But in order to maintain the code. More sketch more code duplicate :frowning:

Using #ifdef to select the appropriate implementation of a function sounds reasonable. That will only include the required code, and if you will only ever attach one kind of display to a flashed device, that makes the most sense.

Just make sure that you’re not defining functions with different signatures for the different cases but that all implementations share the same signatures.

void display_print_text(char *s);

void
display_print_text(char *s)
{
#ifdef DISPLAY_LCD
  // LCD specific implementation here
#endif
#ifdef DISPLAY_GLCD
  // GLCD specific implementation here
#endif
}

That way, you do not need to check which display you’re using when calling the method.