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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:56:35+00:00 2026-05-26T19:56:35+00:00

Compiler is saying illegal indirection on line 3. The IDE says expression must be

  • 0

Compiler is saying “illegal indirection” on line 3. The IDE says “expression must be a pointer to a complete object type”

001 DWORD WINAPI MyCallbackFunction( LPVOID lpvParam )
002 {
003    long value = (long) *lpvParam;
004    ...
005    return 0;
006 }
007
008 BOOL StartMyThread( long value )
009 {
010    DWORD dwThreadId;
011    BOOL result = FALSE;
012    HANDLE hThread = NULL;
013    hThread = CreateThread(NULL, 0, MyCallbackFunction, &value, NULL, &dwThreadId );
014    result = (NULL == hThread);
015    CloseHandle( hThread );
016    return result;
017 }

If I change line 3 to this, it compiles, but crashes…

long value = (long) lpvParam;
  • 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-26T19:56:35+00:00Added an answer on May 26, 2026 at 7:56 pm

    You are trying to deference a void* pointer, which is not allowed. You have to cast it to another pointer type first. Since your parameter is a pointer to a long, you need to do this instead:

    long *value = (long*) lpvParam;
    

    Or, if the thread does not need access to the original variable:

    long value = * (long*) lpvParam;
    

    Seth is right, though. The original variable will be gone by the time the thread actually starts running. If you are trying to pass its value to the thread, do this instead:

    // notice the '&' operator is gone now...
    hThread = CreateThread(NULL, 0, MyCallbackFunction, (LPVOID)value, NULL, &dwThreadId );
    ...    
    long value = (long) lpvParam;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why doesn't the following java code generate a compiler warning saying something like Unsafe
I am getting crazy over this error. Compiler is saying out of scope for
Below code instantiates a derived singleton object based on environment variable. The compiler errors
My fsyacc code is giving a compiler error saying a variable is not found,
I'm getting a compiler error saying that Acme.Business.User is not defined. I have a
Is it possible to have inheritance with no virtual methods? The compiler is saying
The compiler complains on as typeOfState saying that typeOfState could not be found. Why
I am just trying to check whether compiler allows type name as variable name.
In compiler design, why instead of having a caller or callee register saving arrangement,
Visual C++ is saying my void function needs a return value I compiled this

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.