Preprocessor Line Directive

3 minutes
Share the link to this page
Copied
  Completed
The #line directive tells the preprocessor to change the compiler's internally stored line number and filename to a given line number and filename.

Transcript

Hello, welcome to 68th tutorial in the c++ programming series. Just a quick sorry that I didn't do any videos yesterday on the 17th of July 2014, as post usually do, it's nice to day that's the aim for the tutorials and didn't do too it's not there to get was a little busy. I was at my university graduation. So that's over and the witness are on getting back into the swing of things of creating videos. So I will make up for those probably over the next week or so do an extra video for a couple of days. But just a little heads up and a little FYI actually.

Sorry about that. But yeah, let's get into this tutorial. In this problem, we're looking at the preprocessor line directive, the line directive helps the compiler provide more useful and meaningful information. When a compilation error occurs. You specify an annoying number aka an integer that you want it to inform you of an option. error message.

So let's just show you what I mean. And when I mentioned line number, obviously, that line number, the line number doesn't have to be what the actual line risk as you can see this line 16. If you was to put some sort of error here or put the non directive here, then it wouldn't necessarily pump at 16. You could pump out wherever you want, look it, you could use a number as an ID of sorts. That is a good way to think of it so you can easily think I forget on the ID 400 is like yeah, I know where that is. So it's not necessarily a line number.

I like to think of more of an identification number. Okay, so let's just get rid of this. So what you do to do this line direct to do hash line, and then after you put your your optional number, the 999 they Put your error message which is optional. The number is necessary the not the message is optional, I have a trouble declaring integer ABCDE just as a random error, then but a int, A, B, C, D, E, open closed curly brackets, open brackets, close brackets open, open curly bracket, semicolon, and this obviously isn't going to run but that's the whole point of it. So if I were to just run this, we get an error we are here for declaring total declare an integer ABCD. At the moment you can't ID number if you right click and go.

Is Yeah, revealing log and we get here this number right here. 999 is the not number that we specified. So if we just change it to Let's try something else. Free hundred and 70 folders empty. Let me again ever again. But let's see what the error is we'll just go to the errors with the same error message.

And if we just right click on this will be in log, we get the error for Sam to the number 417 right here. So that they that is it for the preprocessor line directive. In the next part of this series, we're going to be looking at the preprocessor error directive. If you have any questions, feel free to message us or support us on our systems coda UK email will be in the description you can comment on this video this directly messages via YouTube. All the required links or source code will also be in the description. As usual.

Thank you for watching and hope you have a great day.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.