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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:40:11+00:00 2026-05-23T19:40:11+00:00

Visual Studio has a size and distance specification chart that says I can do

  • 0

Visual Studio has a size and distance specification chart that says I can do something like this, using the h prefix to specify single byte character string regardless of printf or wprintf:

int main()
{
char test[]= "abc";
_tprintf(_T("%hs\n"),test);
}

But if I compile the same thing with mingw gcc and -Wall I get the following warning:
warning: format '%hs' expects type 'short int *', but argument 2 has type 'char *'

Is what I’m doing an acceptable way to specify a single byte character string in mingw?

Thanks

Edit-This question has been answered below in fair detail. The short answer is yes, it’s an acceptable way to specify a single byte character string in mingw and the warning can be ignored.

  • 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-23T19:40:13+00:00Added an answer on May 23, 2026 at 7:40 pm

    You’ll also note that the Visual Studio docs say:

    Note: The h and l prefixes are Microsoft extensions when used with data of type char.

    I think that this would be more accurate to say, “when used with the 'c' or 's' format specifiers (upper or lower case)”.

    Realize that the GCC compiler really doesn’t know about how Microsoft’s runtime deals with printf() format strings and the warning GCC is giving is tailored to the runtimes that it more normally uses. When building with MinGW, a Microsoft C runtime that’s provided with Windows, msvcrt.dll, is used (though MinGW does provide replacements or wrappers for some library functions). So there is sometimes confusing between what the compiler thinks is OK for a printf() format string and the arguments provided to printf() and what the runtime will actually do.

    For example, until recently, using ll on an integer conversion to format a 64-bit int type wouldn’t work correctly in MinGW. I’m not sure if the ‘fix’ for that occurred in the MinGW support functions or if msvcrt.dll was updated to support the ll modifier (I suspect that msvcrt.dll was updated – I’ll have to check…).

    Anyway, what this boils down to is that regardless of the warnings that GCC gives about the printf() format string, in all likelihood you’ll need to use the MSVC docs for format strings, since its an MS runtime that MinGW will be using. If you don’t like the warngin being generated you might want to consider adding the -Wno-format option to your MinGW build script.

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

Sidebar

Related Questions

I'm using Visual Studio 2008. I'm aware that std::vector has bounds checking with the
I have been using the embedded server that visual studio has to test my
I realize that Visual Studio has the /P option to generate preprocessed files, but
Visual Studio 2008 has built-in unittesting that was previously only available in the Team
I am using Visual Studio Team System 2008 and see it has an Icon
visual studio has an excellent feature for manual code folding by using regions. i
Something has gone wrong with my installation of Visual Studio 2010. The symptoms are:
Visual Studio has certainly gone from strength to strength since humble Visual Studio 6
Visual Studio has a way to import, export your color settings. Does Eclipse have
Visual Studio has ways to automatically create a method. For example, you could double

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.