Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - HelbMePlease

Pages: [1]
1
General / Re: Problem with debugging in VSCode+gdb
« on: August 16, 2023, 05:32:37 pm »
A quick web search lead me to some similar posts, maybe you can find some answers there:

https://stackoverflow.com/questions/56828562/unable-to-see-elements-of-stdvector-with-gcc-in-vs-code
https://stackoverflow.com/questions/64189683/unable-to-inspect-c-stl-content-in-vs-code
Oh thanks, but I already solved this problem with the nice folks over at the discord server. I just needed to use the CMake boilerplate you guys put up on GitHub and download some linux dependencies so the debugger knew how to interpret the data. Should I mark this thread with [SOLVED] marker or do we not do that in these forums?

2
General / Re: Problem with debugging in VSCode+gdb
« on: August 01, 2023, 10:11:51 pm »
Update: it's definitely an SFML-related problem as I tried a very similar scenario with a vector of primitive types and a little class I whipped up for testing and it all worked fine. Only when I tried to use a vector of sf::RectangleShape did the problem reappear.

3
General / Problem with debugging in VSCode+gdb
« on: July 31, 2023, 09:35:56 pm »
Hey everyone,
I used the CMake Tools VSCode extension to set up a debugging environment (I hardly did anything) using the gcc kit. It was all going fine until I tried to inspect the contents of a vector and it shows empty even though I know (almost for certain) it isn't. Here's the relevant code:
void squares(std::vector<sf::RectangleShape> &squares_vec)
{
    for (size_t i = 0; i < 81; i++)
    {
        sf::Color grey(140,140,140);
        sf::Color gainsboro_grey(207,208,207);
        sf::RectangleShape square(sf::Vector2f(70,70));
        square.setFillColor(gainsboro_grey);
        square.setOutlineColor(grey);
        square.setOutlineThickness(3);
        squares_vec.push_back(square);
    }
    std::cout<<"Number of squares in vec: "<<squares_vec.size()<<std::endl;
    place_squares(squares_vec);        
}
 
The std::cout prints 81 squares in vec (as intended) so everything in that function seems okay  but I need the debugger to be working well to debug the subsequent function ( place_squares() ) which is not working okay. What I mean by the debugger is telling me the vector is empty is that is what it shows in the VSCode debugging GUI on the left panel of VSCode, which I am using. Below are some more documents you may find useful.

CMakeLists.txt:

Quote

#This CMakeLists.txt is a frankenstein mixture between what CMake Tools auto generates and some changes I made based on
#this Example CMake script (so it would link the libraries): https://en.sfml-dev.org/forums/index.php?topic=24070.0

cmake_minimum_required(VERSION 3.0.0)
project(sfml-app VERSION 0.1.0 LANGUAGES C CXX)

include(CTest)
enable_testing()

find_package(SFML 2.5 COMPONENTS graphics audio REQUIRED)
add_executable(sfml-app main.cpp)
target_link_libraries(sfml-app sfml-graphics sfml-audio)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
set(SFML_DIR "<sfml root prefix>/lib/cmake/SFML")
include(CPack)

cmake_minimum_required(VERSION 3.1)

project(SFMLTest)

## If you want to link SFML statically
# set(SFML_STATIC_LIBRARIES TRUE)

## In most cases better set in the CMake cache


compile_commands.json:

Quote
[
{
  "directory": "/home/dudefellaman/Desktop/SFML Code/Sudoku/build",
  "command": "/usr/bin/g++   -g -o CMakeFiles/sfml-app.dir/main.cpp.o -c \"/home/dudefellaman/Desktop/SFML Code/Sudoku/main.cpp\"",
  "file": "/home/dudefellaman/Desktop/SFML Code/Sudoku/main.cpp"
}
]

If you need anymore info, ask away!

Pages: [1]