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

  • SEARCH
  • Home
  • 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 3594474
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:43:07+00:00 2026-05-18T19:43:07+00:00

In Visual Studio 2008 (without SP1), I can compile and run this code //

  • 0

In Visual Studio 2008 (without SP1), I can compile and run this code

// vcconsole.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#define NOERROR
#ifdef   /* 

   */  NOERROR
void pr() {
 printf("hello world..\n");
} 
#endif

int _tmain(int argc, _TCHAR* argv[])
{
 pr();
 return 0;
}

But if I manually replace the block comment with spaces :

// vcconsole.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#define NOERROR
#ifdef      

       NOERROR
void pr() {
 printf("hello world..\n");
} 
#endif

int _tmain(int argc, _TCHAR* argv[])
{
 pr();
 return 0;
}

it fails to compile with error:

1>------ Build started: Project: vcconsole, Configuration: Debug Win32 ------
1>Compiling...
1>vcconsole.cpp
1>c:\x64\winproj\vcconsole\vcconsole.cpp(6) : fatal error C1016: #if[n]def expected an identifier
1>Build log was saved at "file://c:\x64\winproj\vcconsole\Debug\BuildLog.htm"
1>vcconsole - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Why the 2 are not equivalent?

This concerns me because I am using a tool to remove all comments from my c++ source code (I need to do this for other reasons) before compiling them. If the 2 are not equivalent somehow, my tool may fail.

  • 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-18T19:43:07+00:00Added an answer on May 18, 2026 at 7:43 pm

    There’s something in the Standard like a comment is replaced by a single space… that effectively removes the newlines. Your tool should do the same.

    Note that under [lex.parses] 2.1.1.3 “Each comment is replaced by one space character.” before 2.1.1.4 “Preprocessing directives are executed and macro invocations are expanded.”.

    As unquiet mind observes, a preprocessor directive only extends from the introductory preprocessor token through to the next newline, so you can’t put the symbol on a subsequent line (unless you use backslash escapes to effectively combine lines in an early parsing phase).

    So, my tentative explanation for Microsoft’s non-compliant preprocessing switch behaviour is: Visual C++ is doing something non-Standard in preserving newlines in comments (probably to help track line numbers), so it then needs to build in some tracking and tolerance for the consequent multi-line preprocessing directives, keeping them working. /P and /E output the non-Standard multi-line directives, but lose that tracking metadata that makes it compilable.

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

Sidebar

Related Questions

I've been using ClickOnce on Visual Studio 2008 SP1 for a while without incident.
How can I create Word files in C# using Visual Studio 2008, without Word
Currently I'm using Visual Studio 2008 (SP1) and developing some code that uses nested
The below code works on Visual Studio 2008 with and without optimization. But it
Can Report Viewer 2010 control be used in Visual studio 2008 (ASP.NET apps) without
Visual Studio Team system 2008 crashes without any error messages whenever I try to
1) Is it possible to use llvm-py on Windows without Visual Studio 2008? Maybe
Visual Studio 2008 insists on indenting HTML like this: <h1> title</h1> <h2> subtitle</h2> where
Visual Studio 2008 I am using the following source code that compiles ok using
visual studio 2008 allows c# code to be segregated into regions is there an

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.