浏览代码

Building even 32-bit drag&drop shell extension using Clang compiler

Source commit: 7e76e02db2a6173570bb055cbcd4bfa4a21be162
Martin Prikryl 3 月之前
父节点
当前提交
58b447c1b2
共有 3 个文件被更改,包括 17 次插入35 次删除
  1. 4 2
      source/DragExt.cbproj
  2. 13 24
      source/dragext/DragExt.cpp
  3. 0 9
      source/dragext/DragExt.h

+ 4 - 2
source/DragExt.cbproj

@@ -32,9 +32,11 @@
         <BCC_AllWarnings>true</BCC_AllWarnings>
         <BCC_AllWarnings>true</BCC_AllWarnings>
         <BCC_ExtendedErrorInfo>true</BCC_ExtendedErrorInfo>
         <BCC_ExtendedErrorInfo>true</BCC_ExtendedErrorInfo>
         <BCC_OptimizeForSpeed>true</BCC_OptimizeForSpeed>
         <BCC_OptimizeForSpeed>true</BCC_OptimizeForSpeed>
-        <BCC_wdlx>false</BCC_wdlx>
+        <BCC_UseClassicCompiler>false</BCC_UseClassicCompiler>
+        <BCC_UserSuppliedOptions>-Wno-c++98-compat-pedantic -Wno-padded</BCC_UserSuppliedOptions>
         <DCC_CBuilderOutput>JPHNE</DCC_CBuilderOutput>
         <DCC_CBuilderOutput>JPHNE</DCC_CBuilderOutput>
         <DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;Vcl;$(DCC_Namespace)</DCC_Namespace>
         <DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;Vcl;$(DCC_Namespace)</DCC_Namespace>
+        <Defines>UNICODE;$(Defines)</Defines>
         <FinalOutputDir>$(FINAL_PATH)\$(Platform)\$(Config)</FinalOutputDir>
         <FinalOutputDir>$(FINAL_PATH)\$(Platform)\$(Config)</FinalOutputDir>
         <ILINK_GenerateImportLibrary>true</ILINK_GenerateImportLibrary>
         <ILINK_GenerateImportLibrary>true</ILINK_GenerateImportLibrary>
         <ILINK_LibraryPath>dragext\;$(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;$(ILINK_LibraryPath)</ILINK_LibraryPath>
         <ILINK_LibraryPath>dragext\;$(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;$(ILINK_LibraryPath)</ILINK_LibraryPath>
@@ -52,7 +54,7 @@
         <VerInfo_Keys>CompanyName=Martin Prikryl;FileDescription=Drag&amp;Drop shell extension for WinSCP ($(Platform));FileVersion=2.1.0.0;InternalName=dragext;LegalCopyright=(c) 2000-2025 Martin Prikryl;LegalTrademarks=;OriginalFilename=dragext.dll;ProductName=WinSCP;ProductVersion=6.6.0.0;ReleaseType=stable;WWW=https://winscp.net/</VerInfo_Keys>
         <VerInfo_Keys>CompanyName=Martin Prikryl;FileDescription=Drag&amp;Drop shell extension for WinSCP ($(Platform));FileVersion=2.1.0.0;InternalName=dragext;LegalCopyright=(c) 2000-2025 Martin Prikryl;LegalTrademarks=;OriginalFilename=dragext.dll;ProductName=WinSCP;ProductVersion=6.6.0.0;ReleaseType=stable;WWW=https://winscp.net/</VerInfo_Keys>
         <VerInfo_Locale>1033</VerInfo_Locale>
         <VerInfo_Locale>1033</VerInfo_Locale>
         <VerInfo_MajorVer>2</VerInfo_MajorVer>
         <VerInfo_MajorVer>2</VerInfo_MajorVer>
-        <VerInfo_MinorVer>1</VerInfo_MinorVer>
+        <VerInfo_MinorVer>2</VerInfo_MinorVer>
     </PropertyGroup>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Base_Win64)'!=''">
     <PropertyGroup Condition="'$(Base_Win64)'!=''">
         <OutputName>DragExt64</OutputName>
         <OutputName>DragExt64</OutputName>

+ 13 - 24
source/dragext/DragExt.cpp

@@ -7,21 +7,20 @@
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 #define LENOF(x) ( (sizeof((x))) / (sizeof(*(x))))
 #define LENOF(x) ( (sizeof((x))) / (sizeof(*(x))))
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
-#include <initguid.h>
-#include <shlguid.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdio.h>
-#pragma warn -inl
+#include <time.h>
+//---------------------------------------------------------------------------
+// prevent the system header files from messing with compiler settings
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wall"
+#include <initguid.h>
+#include <shlguid.h>
 #include <shlobj.h>
 #include <shlobj.h>
-#pragma warn .inl
 #include <olectl.h>
 #include <olectl.h>
-#include <time.h>
-#include "DragExt.h"
+#pragma clang diagnostic pop
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
-#ifdef __BORLANDC__
-#undef STDAPI
-#define STDAPI EXTERN_C __declspec(dllexport) HRESULT STDAPICALLTYPE
-#endif
+#include "DragExt.h"
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 #define Debug(MSG) \
 #define Debug(MSG) \
   if (GLogOn) \
   if (GLogOn) \
@@ -61,11 +60,6 @@ protected:
   unsigned long FReferenceCounter;
   unsigned long FReferenceCounter;
 };
 };
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
-#ifdef _WIN64
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpadded"
-#endif
-//---------------------------------------------------------------------------
 class CShellExt : public IShellExtInit, ICopyHook
 class CShellExt : public IShellExtInit, ICopyHook
 {
 {
 public:
 public:
@@ -91,13 +85,6 @@ protected:
   unsigned long FLastTicks;
   unsigned long FLastTicks;
 };
 };
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
-#ifdef WIN64
-#pragma clang diagnostic pop
-#endif
-//---------------------------------------------------------------------------
-#ifndef __clang__
-#define nullptr 0
-#endif
 static unsigned int GRefThisDll = 0;
 static unsigned int GRefThisDll = 0;
 static bool GEnabled = false;
 static bool GEnabled = false;
 static wchar_t GLogFile[MAX_PATH] = L"";
 static wchar_t GLogFile[MAX_PATH] = L"";
@@ -298,9 +285,11 @@ DllMain(HINSTANCE HInstance, DWORD Reason, LPVOID /*Reserved*/)
   return 1;   // ok
   return 1;   // ok
 }
 }
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
-#ifdef _WIN64
+// There's no dllexport in the header (compbaseapi.h), but we need it to export the function
+// (alternativelly we can use .def file)
+#undef STDAPI
+#define STDAPI EXTERN_C __declspec(dllexport) HRESULT STDAPICALLTYPE
 #pragma clang diagnostic ignored "-Wdll-attribute-on-redeclaration"
 #pragma clang diagnostic ignored "-Wdll-attribute-on-redeclaration"
-#endif
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 STDAPI DllCanUnloadNow(void)
 STDAPI DllCanUnloadNow(void)
 {
 {

+ 0 - 9
source/dragext/DragExt.h

@@ -8,12 +8,6 @@
 #define DRAG_EXT_DUMMY_DIR_PREFIX L"scp"
 #define DRAG_EXT_DUMMY_DIR_PREFIX L"scp"
 #define DRAG_EXT_DUMMY_DIR_PREFIX_LEN 3
 #define DRAG_EXT_DUMMY_DIR_PREFIX_LEN 3
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
-#ifdef _WIN64
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpadded"
-#pragma clang diagnostic ignored "-Wmissing-variable-declarations"
-#endif
-//---------------------------------------------------------------------------
 EXTERN_C const CLSID CLSID_ShellExtension;
 EXTERN_C const CLSID CLSID_ShellExtension;
 DEFINE_GUID(CLSID_ShellExtension, 0xe15e1d68, 0x0d1c, 0x49f7,
 DEFINE_GUID(CLSID_ShellExtension, 0xe15e1d68, 0x0d1c, 0x49f7,
   0xbe, 0xb8, 0x81, 0x2b, 0x1e, 0x00, 0xfa, 0x60 );
   0xbe, 0xb8, 0x81, 0x2b, 0x1e, 0x00, 0xfa, 0x60 );
@@ -42,8 +36,5 @@ struct TDragExtCommStruct
 };
 };
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 #pragma pack(pop)
 #pragma pack(pop)
-#ifdef _WIN64
-#pragma clang diagnostic pop
-#endif
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 #endif // DragExtH
 #endif // DragExtH