Closed centuryhopper closed 3 years ago
Hi @leozhang1
Configure CppHelper.SourcePattern correctly then extension can find source of each header file.
The implementation in the same file will happen if it can't find the source based on configuration.
Hey @amir9480. Yeah I saw that before but I'm not sure how to configure it even after I read it. Is it possible you can make youtube video on it? My header file is in my "public" folder and my cpp file is in my "private" folder. I am trying to get started in C++ in unreal, so this would really help as VS code is my favorite editor.
@leozhang1
For example if this is your structure
- public
- Directory
- Hello.h
- Test.h
- private
- Directory
- Hello.cpp
- Test.cpp
Then your configuration should be like this
"CppHelper.SourcePattern": [
"/public/{FILE}.cpp",
"/public/Directory/{FILE}.cpp"
]
where {FILE} is filename for example Test
.
or use a relative path like this
"CppHelper.SourcePattern": [
"../public/{FILE}.cpp",
"../../public/Directory/{FILE}.cpp"
]
@amir9480 Thank you sir! This example helps, but when I have multiple headers in the public folder and multiple corresponding c++ files in the private folder, they all go to the first one I have, which I can see why, but I'm not sure how to fix it. My guess would be that I would have to make all the implementation files in their own folder to get this to work but I feel like doing that for every C++ file is going to make my project flooded with folders https://imgur.com/a/sibsPUA
@leozhang1
{FILE}
is a placeholder used by the extension. It's gonna be replaced by the extension whenever you use Create implementation
.
Your configuration should be exactly like this:
"CppHelper.SourcePattern": [
"../Public/{FILE}.cpp"
]
@amir9480 Yeah I changed it to public just now because you said so but it still doesn't work :/ https://imgur.com/a/plxBaK3
@leozhang1
Oops, my bad
Path should point from header path to source path
Put Private
instead of Public
.
@amir9480 Yeah I had private before and it works only if i have one file in my private folder. If I have two different cpp files, both of my header files' implementation would go to the first cpp file mentioned in the source pattern, which in this case is MyActor.cpp. And this is not good because I want pawn.h implementations to go into pawn.cpp and actor.h implementations to go into actor.cpp https://imgur.com/a/sibsPUA
@leozhang1
I told you to use {FILE}
.
"CppHelper.SourcePattern": [
"../Private/{FILE}.cpp"
]
@amir9480 ooh okay. I didn't know it was literally {FILE}. I thought that was a placeholder 😅. That seems to have done it! Thank you sir 🤝!
Hello friends,
The "create implementation" option in the context menu is creating the implementation in the header file rather than its .cpp file. How do I fix this?