Click here to Skip to main content
15,882,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I just started working with www.codeproject.com/Articles/5272315/Midi-A-Windows-MIDI-Library-in-Csharp "Midi: A Windows MIDI Library in C#".
What does the following really do? Trying to understand this segment of code:

#if MIDILIB
public
#else
internal
#endif

I understand the definition of what it does but don't know what it "really does". In one file, #if MIDILIB occurs 38 times. The well commented code notes a variety of summaries of what the code that follows each one does, such as:
Represents a MIDI message with a single payload byte.
or
Creates a MIDI message with the specified status and payload.
etc.

TIA

What I have tried:

I have looked online and found nothing and even asked ChatGPT.
Posted
Updated 3-Feb-23 14:56pm
Comments
[no name] 3-Feb-23 22:25pm    
It's confusing because #if .. #endif is typically used to include / exclude an entire statement, and not just one "keyword", as in this case. You have to look at the surrounding code to make full sense of it (declaring something as internal vs public).

1 solution

They are C# preprocessor directives | Microsoft Learn[^]
Quote:
Although the compiler doesn't have a separate preprocessor, the directives described in this section are processed as if there were one. You use them to help in conditional compilation.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900