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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:54:06+00:00 2026-06-10T22:54:06+00:00

I wrote a C++ application on Win64 with these lines: Window* wnd = 0;

  • 0

I wrote a C++ application on Win64 with these lines:

Window* wnd = 0;
long l = reinterpret_cast<long> ( wnd );

The compiler displays the following error at the last line:

error: cast from 'window::Window*' to 'long int' loses precision [-fpermissive] 

I use this value to put it into SetWindowLong (WindowsAPI) function.

I cannot understand this error. I am using MinGW-w64 (ruben build).

  • 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-06-10T22:54:08+00:00Added an answer on June 10, 2026 at 10:54 pm

    Read my original comment.

    The issue is that sizeof(window::Window *) is greater than sizeof(long), meaning you can’t effectively store the value of the pointer in l. This explains the error.

    Now, what you should really want is actually to use SetWindowLongPtr instead.

    Note To write code that is compatible with both 32-bit and 64-bit versions of Windows, use SetWindowLongPtr. When compiling for 32-bit Windows, SetWindowLongPtr is defined as a call to the SetWindowLong function.

    window::Window *wnd = ...;
    HWND handle = ...;
    int index = ...; /* e.g. GWLP_USERDATA */
    LONG_PTR val = reinterpret_cast<LONG_PTR>(wnd);
    SetWindowLongPtr(handle, index, val);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I wrote an application and while deploying shows error in line mCamera=Camera.open(); Where
I keep getting the error in VS 2100 CRT detected that the application wrote
I wrote an application in VB.NET and since I charge by the line, I
We have an application wrote in C#, which broken into several projects. These projects
I wrote an application that re-hosts the Workflow 4 Designer (System.Activities.Presentation.WorkflowDesigner). Activities are discovered
I wrote an application that generates quiz applets. I could't find a portable way
I wrote an application using ASP.NET MVC, in this application I have an Index
I wrote an application which allows people to contribute plugins to extend the functionality.
I wrote an application in JAVA that adds articles to a Joomla site. My
I wrote an application about NFC in android,but I have a problem. 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.