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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:39:52+00:00 2026-05-31T06:39:52+00:00

Visual C++ 10 is shipped with stdlib.h that among other things contains this gem:

  • 0

Visual C++ 10 is shipped with stdlib.h that among other things contains this gem:

template <typename _CountofType, size_t _SizeOfArray>
char (*__countof_helper(UNALIGNED _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];

#define _countof(_Array) (sizeof(*__countof_helper(_Array)) + 0)

which uses a clever template trick to deduce array size and prevent pointers from being passed into __countof.

What’s the purpose of + 0 in the macro definition? What problem does it solve?

  • 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-31T06:39:54+00:00Added an answer on May 31, 2026 at 6:39 am

    Quoting STL from here

    I made this change; I don’t usually hack the CRT, but this one was
    trivial. The + 0 silences a spurious “warning C6260: sizeof * sizeof
    is usually wrong. Did you intend to use a character count or a byte
    count?” from /analyze when someone writes _countof(arr) * sizeof(T).

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

Sidebar

Related Questions

I work on C/C++ using Visual Studio 2008. I believe that I am not
I have a legacy VB (visual basic) 6 application that connects to Oracle 8
Does anybody know of a managed programming language implemented on .NET that contains a
Ok, so I want to run simple opengl program that I've written, on other
In Visual Studio 2008 (without SP1), I can compile and run this code //
I was googling a bit and heard that although stdint.h was not shipped with
Does anyone have a best practice Project Template for Visual Studio 2008 MASM projects?
I'm using Visual Studio 2008 SP1 and a web application that I'm trying to
Currently Visual C++ is shipped with runtime where malloc() is decorated with __declspec( restrict
I have a solution in Visual Studio. It contains about 500 projects. When I

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.