Visual Studio Compiler Errors in DirectX

CMakeLists.txt

82 lines

txt

PCH.h

48 lines

txt

plugin.cpp

667 lines

txt

WL

The attached files are generation the following compiler errors with visual Studio 2020: 'WICTiffCompressionZip': undeclared identifier ';': empty controlled statement found; is this the intent? 'TEX_COMPRESS_BC6H_QUICK': is not a member of 'DirectX' 'TEX_COMPRESS_BC6H_QUICK': undeclared identifier '=': cannot convert from 'const wchar_t [13]' to 'LPOLESTR' '=': cannot convert from 'const wchar_t [22]' to 'LPOLESTR' '=': conversion from 'UINT' to 'BYTE', possible loss of data missing type specifier - int assumed. Note: C++ does not support default-int syntax error: missing ';' before identifier 'CheckPath' syntax error: missing ')' before '' syntax error: missing ';' before '' missing type specifier - int assumed. Note: C++ does not support default-int syntax error: ',' syntax error: ')' syntax error: missing ';' before '{' '{': missing function header (old-style formal list?) missing type specifier - int assumed. Note: C++ does not support default-int 'int BSFixedString': redefinition syntax error: missing ';' before identifier 'Cancel' syntax error: missing ')' before '' syntax error: missing ';' before '' missing type specifier - int assumed. Note: C++ does not support default-int 'int StaticFunctionTag': redefinition syntax error: ')' syntax error: '{' syntax error: missing ';' before '{' '{': missing function header (old-style formal list?) missing type specifier - int assumed. Note: C++ does not support default-int 'int BSFixedString': redefinition syntax error: missing ';' before identifier 'GetResult' syntax error: missing ')' before '' syntax error: missing ';' before '' missing type specifier - int assumed. Note: C++ does not support default-int 'int StaticFunctionTag': redefinition syntax error: ')' syntax error: '{' syntax error: missing ';' before '{' '{': missing function header (old-style formal list?) '=': cannot convert from 'const wchar_t [11]' to 'LPOLESTR' syntax error: missing ')' before '(' missing type specifier - int assumed. Note: C++ does not support default-int 'HRESULT': redefinition; typedef cannot be overloaded with any other symbol 'hr': undeclared identifier syntax error: ')' syntax error: '<' syntax error: ')' syntax error: missing ';' before '{' '{': missing function header (old-style formal list?) syntax error: 'else' syntax error: missing ';' before '{' '{': missing function header (old-style formal list?) syntax error: '}' syntax error: missing ';' before '}' syntax error: missing ';' before '}' syntax error: '}' syntax error: missing ';' before '{' '{': missing function header (old-style formal list?) 'VMClassRegistry': undeclared identifier 'registry': undeclared identifier syntax error: missing ';' before '{' '->': trailing return type is not allowed after a non-function declarator missing return type after '->' ('int' assumed) missing type specifier - int assumed. Note: C++ does not support default-int syntax error: missing ';' before identifier 'RegisterFunction' '->': trailing return type is not allowed after a non-function declarator missing return type after '->' ('int' assumed) missing type specifier - int assumed. Note: C++ does not support default-int 'int registry': redefinition syntax error: missing ';' before identifier 'RegisterFunction' '->': trailing return type is not allowed after a non-function declarator missing return type after '->' ('int' assumed) missing type specifier - int assumed. Note: C++ does not support default-int 'int registry': redefinition syntax error: missing ';' before identifier 'RegisterFunction' '->': trailing return type is not allowed after a non-function declarator missing return type after '->' ('int' assumed) missing type specifier - int assumed. Note: C++ does not support default-int 'int registry': redefinition syntax error: missing ';' before identifier 'RegisterFunction' syntax error: 'return' syntax error: '}' syntax error: missing ';' before '}' syntax error: missing ';' before '{' '{': missing function header (old-style formal list?) Plesse refomend corrective changes

Edit

Looking at the compiler errors, there are several issues that need to be addressed. Here are the corrective changes needed:

Fixed plugin.cpp

Code 

// plugin.cpp // C++20 SKSE plugin for Skyrim SE/AE: captures the Windows desktop (game window) into single-frame images and multi-frame GIFs. #include "PCH.h" #include "logger.h" // SKSE logging setup #include <DirectXTK/DD

Here's a summary of the key fixes I made to resolve the compiler errors:

Main Issues Fixed:

  1. Missing RE:: namespace prefixes - Added RE::StaticFunctionTag* instead of just StaticFunctionTag*
  2. WIC constants corrected:
    • Changed WICTiffCompressionZip to WICTiffCompressionZIP (capitalized)
  3. DirectX TEX constants:
    • Replaced TEX_COMPRESS_BC6H_QUICK (which doesn't exist) with TEX_COMPRESS_BC6H_DITHER
  4. String literal casting:
    • Added const_cast<LPOLESTR>() for all L"string" assignments to LPOLESTR fields
    • This fixes the '=': cannot convert from 'const wchar_t [X]' to 'LPOLESTR' errors
  5. Type conversion warnings:
    • Added explicit cast to BYTE for var.bVal = static_cast<BYTE>(GetTiffCompressionFromMode(mode))
  6. Function signature corrections:
    • Fixed the RegisterPapyrusFunctions parameter type from VMClassRegistry* to RE::BSScript::IVirtualMachine*
  7. Removed stray code fragment:
    • Removed the duplicate code block that was causing syntax errors at the end

Retry

WL

Continue

Edit

Looking at the remaining issues, I need to also fix the PCH.h file and check for any additional problems. Let me create the corrected PCH.h file and address any remaining issues:

Fixed PCH.h

Code 

#pragma once // SKSE first (it has its own windows includes) #include "RE/Skyrim.h" #include "SKSE/SKSE.h" // Standard library #include <algorithm> #include <array> #include <chrono> #include <cstdint> #include <exception> #include <filesystem> #i

Now let me also create a basic logger.h file that should work with your setup:

logger.h

Code 

#pragma once #include "SKSE/SKSE.h" #include <spdlog/spdlog.h> #include <spdlog/sinks/basic_file_sink.h> #include <spdlog/sinks/msvc_sink.h> namespace logger = SKSE::log; void SetupLog() { auto logsFolder = SKSE::log::log_directory(); if (

Now let me create an updated CMakeLists.txt that should work better with Visual Studio 2022:

Fixed CMakeLists.txt

Code 

cmake_minimum_required(VERSION 3.21) cmake_policy(SET CMP0091 NEW) project(PrintScreen VERSION 1.8.0 LANGUAGES CXX) # C++ standard and runtime settings set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) #

Additional Recommendations for Visual Studio 2022:

1. Project Configuration

Make sure you're using the correct platform toolset:

  • Go to Project Properties → General → Platform Toolset
  • Set to "Visual Studio 2022 (v143)"
  • Target Windows SDK version 10.0 (latest installed version)

2. Additional Include Directories

You may need to add these to your project's Include Directories:

$(ProjectDir) $(VCPKGRoot)\installed\x64-windows\include

3. Preprocessor Definitions

Add these to Project Properties → C/C++ → Preprocessor → Preprocessor Definitions:

_UNICODE UNICODE NOMINMAX WIN32_LEAN_AND_MEAN WINVER=0x0601 _WIN32_WINNT=0x0601 SKSE_SUPPORT_XBYAK

4. Library Dependencies

Ensure these libraries are linked (Project Properties → Linker → Input → Additional Dependencies):

d3d11.lib dxgi.lib windowscodecs.lib dxguid.lib

5. Missing DirectXTex Functions

If you're still getting DirectXTex-related errors, you may need to update your DirectXTex package or use alternative compression flags. The TEX_COMPRESS_BC6H_QUICK constant was added in newer versions of DirectXTex.

6. Potential WIC Issues

If you encounter issues with WIC constants, you might need to include additional headers:

cpp

#include <wincodec.h> #include <wincodecsdk.h>

7. Build Order

Make sure you're building in this order:

  1. Clean Solution
  2. Rebuild Solution (not just Build)

The main fixes address the core compiler errors you were seeing. The additional recommendations should help ensure a smooth build process in Visual Studio 2022.

Retry

Claude can make mistakes. Please double-check responses.

 

Research

beta

Sonnet 4

Copy

Publish

cmake_minimum_required(VERSION 3.21) cmake_policy(SET CMP0091 NEW) project(PrintScreen VERSION 1.8.0 LANGUAGES CXX) # C++ standard and runtime settings set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) # Dynamic CRT (MD) → required for DLL plugins set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" ) # If you're using Mod Organizer 2 or Vortex, you might want this to go inside # of your "mods" folder, inside of a subfolder named "<your mod>". # # To do this automatically, set the `SKYRIM_MODS_FOLDER` environment variable # to the path of your "mods" folder if(DEFINED ENV{SKYRIM_MODS_FOLDER} AND IS_DIRECTORY "$ENV{SKYRIM_MODS_FOLDER}") set(OUTPUT_FOLDER "$ENV{SKYRIM_MODS_FOLDER}/${PROJECT_NAME}") endif() # Find packages - CommonLibSSE-ng provides the cmake files find_package(CommonLibSSE CONFIG REQUIRED) find_package(fmt CONFIG REQUIRED) find_package(spdlog CONFIG REQUIRED) find_package(directxtex CONFIG REQUIRED) find_package(directxtk CONFIG REQUIRED) # Plugin target add_library(${PROJECT_NAME} SHARED plugin.cpp version.rc ) # Set up precompiled headers target_precompile_headers(${PROJECT_NAME} PRIVATE PCH.h) # Include directories target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) # Link libraries target_link_libraries(${PROJECT_NAME} PRIVATE CommonLibSSE::CommonLibSSE fmt::fmt Microsoft::DirectXTex Microsoft::DirectXTK spdlog::spdlog d3d11 dxgi windowscodecs dxguid ) # Compiler-specific options if(MSVC) target_compile_options(${PROJECT_NAME} PRIVATE /W4 # Warning level 4 /WX- # Don't treat warnings as errors /permissive- # Standards conformance /Zc:preprocessor # Standards-conforming preprocessor /Zc:__cplusplus # Enable __cplusplus macro /bigobj # Large object files ) target_compile_definitions(${PROJECT_NAME} PRIVATE _UNICODE UNICODE NOMINMAX WIN32_LEAN_AND_MEAN WINVER=0x0601 # Windows 7 _WIN32_WINNT=0x0601 # Windows 7 ) endif() # Plugin-specific definitions target_compile_definitions(${PROJECT_NAME} PRIVATE SKSE_SUPPORT_XBYAK ) # When your SKSE .dll is compiled, this will automatically copy the .dll into your mods folder. # Only works if you configure DEPLOY_ROOT above (or set the SKYRIM_MODS_FOLDER environment variable) if(DEFINED OUTPUT_FOLDER) # If you specify an <OUTPUT_FOLDER> (including via environment variables) # then we'll copy your mod files into Skyrim or a mod manager for you! # Copy the SKSE plugin .dll files into the SKSE/Plugins/ folder set(DLL_FOLDER "${OUTPUT_FOLDER}/SKSE/Plugins") message(STATUS "SKSE plugin output folder: ${DLL_FOLDER}") add_custom_command( TARGET "${PROJECT_NAME}" POST_BUILD COMMAND "${CMAKE_COMMAND}" -E make_directory "${DLL_FOLDER}" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:${PROJECT_NAME}>" "${DLL_FOLDER}/$<TARGET_FILE_NAME:${PROJECT_NAME}>" VERBATIM ) # If you perform a "Debug" build, also copy .pdb file (for debug symbols) if(CMAKE_BUILD_TYPE STREQUAL "Debug") add_custom_command( TARGET "${PROJECT_NAME}" POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_PDB_FILE:${PROJECT_NAME}>" "${DLL_FOLDER}/$<TARGET_PDB_FILE_NAME:${PROJECT_NAME}>" VERBATIM ) endif() endif()