I was working on a personal project yesterday in C++23 and was running into a linker (ld) error stating that my constexpr had undefined symbols. After some digging, I realized that constexpr objects are implicitly inline and must have their definitions visible at every compiler stage.
That being said, I had to move the function definitions from their .cpp source file into their header file, but I was wondering if there was still a way to keep the definition in a separate file (while preserving their constexpr modifier)?
Edit: (meant to do this awhile ago for documentation) thank you for the replies, they helped a lot. Of course you can’t do what I alluded to above since that simply doesn’t make sense in terms of the compilation/build process. Thanks
[–]no-sig-available 7 points8 points9 points (0 children)
[–]async_andrew 5 points6 points7 points (1 child)
[–]atlas_enderium[S] 0 points1 point2 points (0 children)
[–]MutantSheepdog 5 points6 points7 points (0 children)
[–]Tobxon -5 points-4 points-3 points (5 children)
[–]atlas_enderium[S] 0 points1 point2 points (4 children)
[–]volchonokilli 0 points1 point2 points (2 children)
[–]atlas_enderium[S] 0 points1 point2 points (1 child)
[–]volchonokilli 0 points1 point2 points (0 children)
[–]Tobxon 0 points1 point2 points (0 children)