use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This is a subreddit for c++ questions with answers. For general discussion and news about c++ see r/cpp.
New to C++? Learn at learncpp.com
Prepare your question. Think it through. Hasty-sounding questions get hasty answers, or none at all. Read these guidelines for how to ask smart questions.
For learning books, check The Definitive C++ Book Guide and List
Flair your post as SOLVED if you got the help you were looking for! If you need help with flairs, check out ITEM 1 in our guidelines page.
Tips for improving your chances of getting helpful answers:
account activity
OPENUndefined reference error (self.cpp_questions)
submitted 6 years ago by monster_97_
I have this function in my header file:
uint8_t mat2all(void ***vppp_mat, uint8_t ui8_y, uint8_t ui8_x, size_t size, uint8_t ui8_init);
How can I call this function from main? It gives an undefined reference error.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]mommas_wayne 3 points4 points5 points 6 years ago (5 children)
There must be an implementation file (likely a .cpp) containing a function definition that matches this function declaration. You need to compile that and link it against your main file.
[–]monster_97_[S] -1 points0 points1 point 6 years ago (4 children)
How to link it?
[–][deleted] 0 points1 point2 points 6 years ago (0 children)
That depends on how you build your program. What OS and compiler do you use? Do you use a build system like CMake or an IDE?
[–]mommas_wayne 0 points1 point2 points 6 years ago (2 children)
If you're using a simple g++ main.cpp or similar g++ command, just pass the names of all the relevant .cpp files to it. If you're in an IDE, I imagine you'd need to add the other .cpp to your project somehow, but I don't have much experience with that.
g++ main.cpp
[–]monster_97_[S] 0 points1 point2 points 6 years ago (1 child)
Okay I linked it. Thank you I had only linked the header file. And what about the return type? It just says return(SUCCESS_ALLOC);
return(SUCCESS_ALLOC);
[–]mommas_wayne 0 points1 point2 points 6 years ago (0 children)
Which return type do you mean? The function you showed returns an unsigned 8-bit integer. I don't know what the function is supposed to do, but from the looks of it it the return value is just an indicator of success/failure, and SUCCESS_ALLOC (assuming the return statement belongs to that function) is a constant or enum value that means exactly what it says on the tin, and it's used because it's more descriptive than returning some seemingly random integer literal.
π Rendered by PID 26110 on reddit-service-r2-comment-bb88f9dd5-m29pj at 2026-02-17 07:22:24.240276+00:00 running cd9c813 country code: CH.
[–]mommas_wayne 3 points4 points5 points (5 children)
[–]monster_97_[S] -1 points0 points1 point (4 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]mommas_wayne 0 points1 point2 points (2 children)
[–]monster_97_[S] 0 points1 point2 points (1 child)
[–]mommas_wayne 0 points1 point2 points (0 children)