Skip to content

Instantly share code, notes, and snippets.

@santagada
Created January 22, 2018 13:34
Show Gist options
  • Save santagada/7977e929d31c629c4bf18ebb987f6be3 to your computer and use it in GitHub Desktop.
Save santagada/7977e929d31c629c4bf18ebb987f6be3 to your computer and use it in GitHub Desktop.
clang vs cl double definition
clang-cl main.cpp -c -o main.o
In file included from main.cpp:3:
./win32.h(29,21): error: conflicting types for 'GetCursorPos'
WIN32_IMPORT(BOOL) GetCursorPos(LPPOINT lpPoint);
^
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winuser.h(9110,1): note: previous declaration is here
GetCursorPos(
^
1 error generated.
cl main.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.12.25834 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
main.cpp
Microsoft (R) Incremental Linker Version 14.12.25834.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:main.exe
main.obj
clang-cl main.cpp -c -o main.o
cl main.cpp
#include<stdio.h>
#include<windows.h>
#include "win32.h"
int main(void) {
printf("Hello World");
}
#pragma once
#include<stdint.h>
#ifdef __VISUAL_C__
#pragma comment(lib, "comctl32.lib")
#endif
// Win32 Import calling conventions
#define WIN32_API __stdcall
#define WIN32_IMPORT(inReturnType) __declspec(dllimport) inReturnType WIN32_API
//---------------------------------------------------------------------------------------------------------------------
// Win32 namespace
//---------------------------------------------------------------------------------------------------------------------
namespace Win32 {
extern "C" {
typedef int BOOL;
typedef int32_t LONG;
struct POINT
{
LONG x;
LONG y;
};
typedef POINT *LPPOINT;
WIN32_IMPORT(BOOL) GetCursorPos(LPPOINT lpPoint);
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment