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 410085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:51:14+00:00 2026-05-12T17:51:14+00:00

Under MSVC 9.0, this fails. Under g++ this compiles. If we take out the

  • 0

Under MSVC 9.0, this fails. Under g++ this compiles. If we take out the macro then the non-macro version 76-79 compiles. Any ideas?

03: #include <iostream>
04: #include <sstream>
67: #define MAKESTRING(msg, v) \
68:        do { \
69:          std::ostringstream s; \
70:          s << msg; \ 
71:          v = s.str(); \
72:        } while(false)
73:        
74:        int main(void)
75:        { 
76:          std::ostringstream oss;
77:          std::string str;
78:          oss << "foo" << "bar";
79:          str = oss.str();
80:        
81:          MAKESTRING("foo" << "bar", str);
82:         }

testenv.cpp(71) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
testenv.cpp(71) : error C2065: 's' : undeclared identifier
testenv.cpp(71) : error C2228: left of '.str' must have class/struct/union
1>        type is ''unknown-type''
testenv.cpp(72) : error C2059: syntax error : '}'
testenv.cpp(72) : error C2143: syntax error : missing ';' before '}'
testenv.cpp(72) : error C2059: syntax error : '}'
testenv.cpp(75) : error C2143: syntax error : missing ';' before '{'
testenv.cpp(75) : error C2447: '{' : missing function header (old-style formal list?)
testenv.cpp(81) : error C2017: illegal escape sequence
testenv.cpp(126) : fatal error C1004: unexpected end-of-file found
  • 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-12T17:51:15+00:00Added an answer on May 12, 2026 at 5:51 pm

    I would make sure that you don’t have any trailing whitespace after the backslashes that you use to separate the lines of your macro. Since the compiler is reporting line numbers that are within your macro definition, it means the preprocessor hasn’t quite done what you expect.

    Also try running this with the MSVC /E compile option to see what the preprocessed source looks like.

    Actually, even in the source code you pasted into your question, there is a trailing space on line 70. 🙂

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

Sidebar

Related Questions

std::string s(foo); sprintf(buf,%s,s); Why at least under MSVC 2010 this line of code doesn't
Under what circumstances (if any) would you allow an application to change its underlying
I know I'm reaching for straws here, but this one is a mystery... any
In MSVC++ #include files are searched for differently depending on whether the file is
Under what circumstances (if any) would the signal SIGSTKFLT be synchronously raised by the
Under Windows 7 I created a custom autostart entry for an usb device. This
Under my project folder, I find the following folder: Bin\Debug\ This folder has DLLs
Under my relative layout, I put in a Textview and then a TextField (both
Under Delphi XE, is there an ANSI version for Copy? I am using Copy
Under my VS2010 solution I've this situation: WEBSITE Library1 Library2 On global.asax.cs I initialize

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.