Say you had a header file named Add.h. Would the program link if you had
#ifndef ADD_H
#define Add_H
as your include guards?
Edit: Header file
#include <iostream>
using namespace std;
#ifndef _RATIONAL_H
#define _Rational_H
class Rational
{
long long _p;
long long _q;
void simp();
public:
Rational();
Rational( long long P, long long Q = 1);
Rational( const Rational& );
};
#endif
Yes, macros are case sensitive in C++. It's probably a good rule of thumb to assume that everything in most programming languages is case sensitive. In only a few languages would you be able to access, for example, foo
and Foo
as the same variable (I'm thinking Visual Basic - not sure how many others there are).
If you're unsure with something as simple as this, the easiest thing to do would be to try it out with your own compiler :)
Edit: To know whether or not it does actually work, and the linker isn't just overlooking it because it doesn't necessarily need to be defined (might happen depending on the ifdef logic/circumstances) try the following code:
#include <iostream>
#define TEST
bool success = false;
#ifdef Test
bool success = true;
#endif
void main() {
std::cout << success << std::endl;
system("pause"); //Wait to press enter before closing
}
If the console displays the number 1 (std::cout converts true
to 1 and false
to 0, unless you tell it to do otherwise) then the macros are, indeed, case insensitive
Update: I just tried compiling the above code in Visual Studio 2015, and it does give an output of 0
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With