Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 575621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:57:37+00:00 2026-05-13T13:57:37+00:00

i have a question about how to get the current line number while compiling

  • 0

i have a question about how to get the current line number while compiling of the VS C++ compiler, IF its possible of course.
I know its possible to use the LINE Macro from the preprocessor, but the results i get are not correct (well, at least not what i want).

Please tell me its possible 🙂

Thanks in advance

edit:
I think i found my mistake with using the __LINE__ macro. I feel a kinda stupid now.. I think i have to go to bed (after some time you are not creating/adding anything new but destroying what you have done so far). Problem solved, thanks all for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T13:57:37+00:00Added an answer on May 13, 2026 at 1:57 pm

    Ok…to explain a bit better, as I think you have misunderstood the implications of the __LINE__ macro…

    Consider three source files:

    /* Source1.c */
    ...list of headers & functions ....
    if (!(fp = fopen("foo.blah", "r"))){
       fprintf(stderr, "Error in %s @ line: %d: Could not open foo.blah\n", __FILE__, __LINE__);
    }
    
    /* Source2.c */
    ...list of headers & functions ....
    if (!(p = (char *)malloc((10 * sizeof(char)) + 1)))){
       fprintf(stderr, "Error in %s @ line: %d: Could not malloc\n", __FILE__, __LINE__);
    }
    
    /* Source3.c */
    ...list of headers & functions ....
    if (!(ptr = (char *)malloc((50 * sizeof(char)) + 1)))){
       fprintf(stderr, "Error in %s @ line: %d: Could not malloc\n", __FILE__, __LINE__);
    }
    

    Suppose those three files are compiled and linked into an executable called foo.exe and runtime errors appear, nitpicky aside, you would get:

    Error in source2.c @ line 25: Could not malloc
    Error in source1.c @ line 50: Could not open foo.blah
    Error in source3.c @ line 33: Could not malloc
    

    The total size of the project sources in terms of line count, does not mean that those lines are out of sync, regardless of what was pre-processed. I hope I have explained it somewhat easier for you to understand in aiding your reasoning behind the usage of the __LINE__ macro.

    Hope this helps,
    Best regards,
    Tom.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 294k
  • Answers 294k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It seems that you are compiling the same BlogTableItemCell class… May 13, 2026 at 6:40 pm
  • Editorial Team
    Editorial Team added an answer Levenshtein algorithm: http://en.wikipedia.org/wiki/Levenshtein_distance Anything other than a result of zero… May 13, 2026 at 6:40 pm
  • Editorial Team
    Editorial Team added an answer Elements that are not set runat="server" are considered plain text… May 13, 2026 at 6:40 pm

Related Questions

I have a configuration format similar to *.sln format, so take the following as
I am currently using generators as a quick way to get the progress of
I have made a simple webcam based application that detects the edges of motion
OK, another road bump in my current project. I have never had form elements
I have a table that has about 1/2 million records in it. Each month

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.