Closed leavesandlemmas closed 3 months ago
That's a lot of questions, I will try to answer them one at a time.
What does the .clang-format file do? This was generated automatically? How ?
This is a configuration file for a tool called clang-format (https://clang.llvm.org/docs/ClangFormat.html). It can automatically format your c++ source code so that you don't have to worry about keeping the source code clean and easy to read.
What does CMakeLists.txt do?
This is a configuration file for a build system called CMake (https://cmake.org). When building application that needs to be cross-platform, we like to use CMake to generate the build configurations (such as a Makefile) that is suitable for the targeting system. It also help handles the libraries dependencies as well as running tests (as part of the development cycle).
I understand that the environment.yml file specifies a python environment (libraries used here in), but what's its purpose? Was this file generated automatically?
In our group, we like to use conda
to create a sandboxed environment to avoid dependencies issues that often plagues the development process. This file is manually generated based on the software needs, and can be used to create a conda
environment with a command like conda env create -f environment.yml
(on UNIX-like system). This is very handy when you are working on multiple projects with different (if not conflicting) dependencies.
I understand the purpose of .gitignore; just learned that at the new job. How did you generate this one? I am guessing you copied one from another project?
Depending on the project, I often ask my developers to use Github's template for single language project. For more complicated ones, we like to use https://www.toptal.com/developers/gitignore/.
So you declare the parameters as a struct , then update the struct with a json file?
Basically yes, the struct data structure helps organize simulation configuration, making it easier to be updated with an input file as you requested.
What's the purpose of the forward declarations? Is that a style thing ? Basically a list of functions and their types?
When compiler is trying to compile a source code into an object, it is reading the source code from top to bottom. Forward declaration basically tells the compiler that I have this function defined somewhere else, so just trust me when you encounter them later in this file even if you haven't seen it. Without it, you will have to make sure the function is fully defined in the source code before you can call them.
Several of the headers like tbb.h and H5Cpp.h aren't in the c++ standard library right? My compiler (MinGW-W64 x86_64-msvcrt-posix-seh,13.1.0) fails to compile.
You need to use the environment.yml
to create a sandboxed development environment, and conda
will install both tbb
(thread building block, feature from intel's one api) and HDF5.
So if a function is declared, then called but not yet defined, the compiler will still fill in the correction definition?
Did you write comments to work with doxygen? I learned about that here, I was wondering what the comments like:
Yes, this will help with the documentation generation where the API documentation can be generated automatically
So if a function is declared, then called but not yet defined, the compiler will still fill in the correction definition?
Yes, the compiler will trust the developer that the function will be defined somewhere and will be made available during runtime
Could you explain or point me to a reference for the syntax here? I know that auto automatically deduces the correct type.
Yes, auto
is the modern c++ way to simplify the complex c++ syntax. If you learn c++ in the 90s or early 2000, you should really read up on modern c++ syntax. Here is a good starting point: https://github.com/AnthonyCalandra/modern-cpp-features
for (auto& slice : grid)
:
for
: keyword to tell compiler this is a for loopauto
: ask compiler to check the element data type in the iterable container grid
and deduce the correct data type for the iterator slice
.& slice
: use the address, not copying the valslice : grid
: iterating over the container grid (in this case, a std::vector
), and set the iterator to slice
.I think I have answer all the questions there are for the moment. Ping me if you have any additional questions.
Could you explain or point me to a reference for the syntax here? I know that auto automatically deduces the correct type.
Yes,
auto
is the modern c++ way to simplify the complex c++ syntax. If you learn c++ in the 90s or early 2000, you should really read up on modern c++ syntax. Here is a good starting point: https://github.com/AnthonyCalandra/modern-cpp-features
I dont think ever I really learned c++ syntax... just bits and pieces from reading code and messing around with it.
Thanks @KedoKudo Ill make a new issue if i have more questions.
@KedoKudo I finally have time to ask some questions about the C++ implementation / code,
First some questions about files:
.clang-format
file do? This was generated automatically? How ?CMakeLists.txt
do?environment.yml
file specifies a python environment (libraries used here in), but what's its purpose? Was this file generated automatically?.gitignore
; just learned that at the new job. How did you generate this one? I am guessing you copied one from another project?Questions about the implementation in
main.cpp
So you declare the parameters as a
struct
, then update the struct with a json file?forward declarations
? Is that a style thing ? Basically a list of functions and their types?tbb.h
andH5Cpp.h
aren't in the c++ standard library right? My compiler (MinGW-W64 x86_64-msvcrt-posix-seh,13.1.0) fails to compile.are for.
Could you explain or point me to a reference for the syntax here? I know that
auto
automatically deduces the correct type.Or is this some notation for
std::vector
?I will probably have more later (or follow ups).