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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:54:44+00:00 2026-05-27T04:54:44+00:00

Getting a LNK2005 already defined in GUI.obj for a function pointer in PAL.h //GUI.cpp

  • 0

Getting a LNK2005 “already defined in GUI.obj” for a function pointer in PAL.h

//GUI.cpp
#include "PAL.h"

//PAL.h
#define PAL_INCLUDE
int (*addPAL)( int, void(*)(), void(*)() );

//main.cpp
#include "GUI.h"
#ifndef PAL_INCLUDE
#include "PAL.h"
#endif

Have I misunderstood the nature of includes and #ifndef?

  • 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-27T04:54:44+00:00Added an answer on May 27, 2026 at 4:54 am

    You’re getting the error probably because the preprocessor is processing main.cpp before GUI.cpp.
    Try changing the content of your PAL.h to this:

     #ifndef PAL_INCLUDED
     #define PAL_INCLUDED
     // definitions
     #endif
    

    Reference

    Include guard

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

Sidebar

Related Questions

I am getting this linker error. mfcs80.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in
I'm getting error LNK2005: bool __cdecl hasLogin(void) (?hasLogin@@YA_NXZ) already defined in B.obj error. func
getting this 1>main_display.obj : error LNK2005: struct ALLEGRO_DISPLAY * main_display (?main_display@@3PAUALLEGRO_DISPLAY@@A) already defined in
I'm getting the LNK2005: already defined in (...) error when building my project in
I'm getting this error from compilator: 1>Linking... 1>main.obj : error LNK2005: int g_win_flags (?g_win_flags@@3HA)
having trouble getting my directx going I get the following error 1>Linking... 1>main.obj :
#include stdafx.h #include <windows.h> #include <winsock.h> #include <stdio.h> int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR IpCmdLine,int
I am getting linker errors that suggest I am not using #ifndef and #define.
1>GameWinMain.obj : error LNK2005: bool __cdecl BPredicate(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct
I have a file structure like this: file1.h extern const char *build_info[][3]; file1.cpp #include

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.