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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:50:46+00:00 2026-05-29T18:50:46+00:00

I am currently porting a program developed on Linux to Win32. Amongst other problems,

  • 0

I am currently porting a program developed on Linux to Win32. Amongst other problems, I have one that is pretty weird.
A header file contains something like this:

namespace Networking {
  struct  MetaStruct
  {
    int   iDataType;
    int   iDataSize;
    void* pData;
  };

  const int MetaStructSize = sizeof(MetaStruct) - sizeof(MetaStruct::pData);
};

This compiles fine on fine on Linux, but I get this error when compiling for Win32 using VS2010:
Networking.hpp(50): error C2070: '': illegal sizeof operand

I tried adding the Networking:: before MetaStruct but it doesn’t change anything. The weird thing is VS2010 gives me the correct value of the sizeof when I hover it with the mouse, but won’t compile it. Why?

  • 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-29T18:50:47+00:00Added an answer on May 29, 2026 at 6:50 pm

    In C++03 There are two forms of sizeof expressions (see ISO/IEC 14882:2003 5.3.3 [expr.sizeof]).

    sizeof unary-expression
    sizeof ( type-id )
    

    MetaStruct::pData is neither a valid expression (resolving to an object type) nor the name of a type.

    You would have to do

    sizeof( void* )
    

    or

    sizeof MetaStruct().pData
    

    Update: Thanks to @hvd who points out that this should actually be legal in C++11 now.

    You can now use an id-expression that refers to a non-static member of a class in contexts where it isn’t evaluated. Evidently this isn’t supported by VS2010.

    There’s also a new form of sizeof in C++11: sizeof ... ( identifier ) but that’s not relevant here.

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

Sidebar

Related Questions

I have some code, that I'm currently porting from OS X to Linux (console
I'm currently porting a heap of code that has previously only been compiled with
I am currently tasked with porting our website code onto a linux server (from
I'm currently porting an ASP.NET WebForms application to ASP.NET MVC. In one of the
I'm currently porting an app that was written for Windows Mobile 2003 (compact framework
I've a C++ project that I'm currently porting from VS2008 to VS2010. When I
I am porting an existing cross-platform program I have made in C++ and with
I currently have a table with a repeater that is being filled with data
Currently porting an application to Windows Phone 7 I've encountered a problem that should
I'm currently porting a pretty basic gallery application from PHP to Go. This application

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.