use of predefined macros.

Could anybody please let me know how do I use predefined macros in the code?
I am trying the same thing mentioned in the tutorial

1
2
3
4
5
6
7
8
9
10
11
#include<iostream>
using namespace std;

int main()
{
  cout << "this is line number\n"<<_LINE_<<endl;
  cout << "of file\n"<<_FILE_<<endl;
  cout << "at\n"<<_DATE_<<endl;

 return 0;
}


However I get following error

std_directives.cpp:6:36: error: ‘_LINE_’ was not declared in this scope
std_directives.cpp:7:24: error: ‘_FILE_’ was not declared in this scope
std_directives.cpp:8:19: error: ‘_DATE_’ was not declared in this scope


I guess I am missing something here. Please explain. Thanks in advance :)
Yes, you are missing an extra underscore before and after. It is __FILE__, not _FILE_; it is __LINE__, not _LINE_.
oops..you are right ! thanks a lot. It now works :)
Topic archived. No new replies allowed.