gpt4 book ai didi

xcode - 项目 header Xcode 11中的Cant访问变量或类型

转载 作者:行者123 更新时间:2023-12-02 11:10:09 25 4
gpt4 key购买 nike

我不太确定发生了什么。我今天登录计算机并尝试编译我的游戏代码,但是由于某些原因,尽管前一天工作了,但一切都停止了工作。我没有碰它,所有的错误似乎都与索引我的头文件有关。

我提供了所有可以帮助我解决问题的背景图像。

main.hpp
player.cpp
block.hpp

另外,这里是一个包含完整错误日志的pastebin和一个包含我所有代码的GitHub存储库。

https://github.com/KangarooCoder/TSA-Video-Game-Sophmore-Year

https://pastebin.com/hwGzLw7R

CompileC /Users/ksbilodeau/Desktop/Projects/Game/build/Game.build/Debug/Game.build/Objects-normal-ubsan/x86_64/block.o /Users/ksbilodeau/Desktop/Projects/Game/Game/block.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'Game' from project 'Game')
cd /Users/ksbilodeau/Desktop/Projects/Game
export LANG=en_US.US-ASCII
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -target x86_64-apple-macos10.14 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu++14 -stdlib=libc++ -fmodules -gmodules -fmodules-cache-path=/Users/ksbilodeau/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/ksbilodeau/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wdocumentation -Wunreachable-code -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DDEBUG=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -g -fvisibility-inlines-hidden -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wno-semicolon-before-method-body -Wunguarded-availability -fprofile-instr-generate -fcoverage-mapping -fsanitize=undefined -fno-sanitize=enum,return,float-divide-by-zero,function,vptr -index-store-path /Users/ksbilodeau/Library/Developer/Xcode/DerivedData/Game-gvfjrrwteiywkrbuhfwlprzuioif/Index/DataStore -iquote /Users/ksbilodeau/Desktop/Projects/Game/build/Game.build/Debug/Game.build/Game-generated-files.hmap -I/Users/ksbilodeau/Desktop/Projects/Game/build/Game.build/Debug/Game.build/Game-own-target-headers.hmap -I/Users/ksbilodeau/Desktop/Projects/Game/build/Game.build/Debug/Game.build/Game-all-target-headers.hmap -iquote /Users/ksbilodeau/Desktop/Projects/Game/build/Game.build/Debug/Game.build/Game-project-headers.hmap -I/Users/ksbilodeau/Desktop/Projects/Game/build/Debug/include -I/Users/ksbilodeau/Desktop/Projects/Game/build/Game.build/Debug/Game.build/DerivedSources-normal/x86_64 -I/Users/ksbilodeau/Desktop/Projects/Game/build/Game.build/Debug/Game.build/DerivedSources/x86_64 -I/Users/ksbilodeau/Desktop/Projects/Game/build/Game.build/Debug/Game.build/DerivedSources -F/Users/ksbilodeau/Desktop/Projects/Game/build/Debug -F/Library/Frameworks -D_THREAD_SAFE -I/usr/local/include/SDL2 -MMD -MT dependencies -MF /Users/ksbilodeau/Desktop/Projects/Game/build/Game.build/Debug/Game.build/Objects-normal-ubsan/x86_64/block.d --serialize-diagnostics /Users/ksbilodeau/Desktop/Projects/Game/build/Game.build/Debug/Game.build/Objects-normal-ubsan/x86_64/block.dia -c /Users/ksbilodeau/Desktop/Projects/Game/Game/block.cpp -o /Users/ksbilodeau/Desktop/Projects/Game/build/Game.build/Debug/Game.build/Objects-normal-ubsan/x86_64/block.o

In file included from /Users/ksbilodeau/Desktop/Projects/Game/Game/block.cpp:9:
In file included from /Users/ksbilodeau/Desktop/Projects/Game/Game/main.hpp:16:
/Users/ksbilodeau/Desktop/Projects/Game/Game/player.cpp:49:5: error: use of undeclared identifier 'gMap'
gMap.loadBlock(mRect.x / TILE_WIDTH, mRect.y / TILE_HEIGHT);
^
/Users/ksbilodeau/Desktop/Projects/Game/Game/player.cpp:49:30: error: use of undeclared identifier 'TILE_WIDTH'
gMap.loadBlock(mRect.x / TILE_WIDTH, mRect.y / TILE_HEIGHT);
^
/Users/ksbilodeau/Desktop/Projects/Game/Game/player.cpp:49:52: error: use of undeclared identifier 'TILE_HEIGHT'
gMap.loadBlock(mRect.x / TILE_WIDTH, mRect.y / TILE_HEIGHT);
^
/Users/ksbilodeau/Desktop/Projects/Game/Game/player.cpp:113:5: error: use of undeclared identifier 'camera'
camera.x = mRect.x - (camera.w / 2);
^
/Users/ksbilodeau/Desktop/Projects/Game/Game/player.cpp:113:27: error: use of undeclared identifier 'camera'
camera.x = mRect.x - (camera.w / 2);
^
/Users/ksbilodeau/Desktop/Projects/Game/Game/player.cpp:114:5: error: use of undeclared identifier 'camera'
camera.y = mRect.y - (camera.h / 2);
^
/Users/ksbilodeau/Desktop/Projects/Game/Game/player.cpp:114:27: error: use of undeclared identifier 'camera'
camera.y = mRect.y - (camera.h / 2);
^
In file included from /Users/ksbilodeau/Desktop/Projects/Game/Game/block.cpp:9:
In file included from /Users/ksbilodeau/Desktop/Projects/Game/Game/main.hpp:17:
In file included from /Users/ksbilodeau/Desktop/Projects/Game/Game/map.cpp:9:
In file included from /Users/ksbilodeau/Desktop/Projects/Game/Game/map.hpp:16:
/Users/ksbilodeau/Desktop/Projects/Game/Game/block.hpp:49:34: error: use of undeclared identifier 'BLOCK_WIDTH'
std::array<std::array<KTile, BLOCK_WIDTH>, BLOCK_HEIGHT> mTiles;
^
/Users/ksbilodeau/Desktop/Projects/Game/Game/block.hpp:49:46: error: expected a type
std::array<std::array<KTile, BLOCK_WIDTH>, BLOCK_HEIGHT> mTiles;
^
In file included from /Users/ksbilodeau/Desktop/Projects/Game/Game/block.cpp:9:
In file included from /Users/ksbilodeau/Desktop/Projects/Game/Game/main.hpp:17:
/Users/ksbilodeau/Desktop/Projects/Game/Game/map.cpp:36:34: error: use of undeclared identifier 'gTile2'
block.setDefaultTileType(gTile2);
^
In file included from /Users/ksbilodeau/Desktop/Projects/Game/Game/block.cpp:9:
In file included from /Users/ksbilodeau/Desktop/Projects/Game/Game/main.hpp:17:
In file included from /Users/ksbilodeau/Desktop/Projects/Game/Game/map.cpp:9:
In file included from /Users/ksbilodeau/Desktop/Projects/Game/Game/map.hpp:14:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/map:798:41: error: binding value of type 'const pair<...>' to reference to type 'pair<...>' drops 'const' qualifier
reference operator*() const {return __i_->__get_value();}
^~~~~~~~~~~~~~~~~~~
In file included from /Users/ksbilodeau/Desktop/Projects/Game/Game/block.cpp:9:
In file included from /Users/ksbilodeau/Desktop/Projects/Game/Game/main.hpp:17:
/Users/ksbilodeau/Desktop/Projects/Game/Game/map.cpp:44:61: note: in instantiation of member function 'std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::__value_type<std::__1::pair<int, int>, Block>, std::__1::__tree_node<std::__1::__value_type<std::__1::pair<int, int>, Block>, void *> *, long> >::operator*' requested here
for (std::pair<const std::pair<int, int>, Block> &block : mBlockList)
^
11 errors generated.

最佳答案

好的,花了很长时间,但是我相信我已经发现了我的问题。我知道问题出在其他hpp文件中,包括main.hpp。从所有hpp文件中删除它后,我必须在所有cpp文件中包含main.hpp。我相信我必须这样做,因为 header 后卫阻止我进行循环包含,但我不确定。希望这可以帮助其他最终遇到和我一样的问题的人!

关于xcode - 项目 header Xcode 11中的Cant访问变量或类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59082119/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com