include

Why create an include/ directory in C and C++ projects?

99封情书 提交于 2021-02-05 19:39:02
问题 When I work on my personal C and C++ projects I usually put file.h and file.cpp in the same directory and then file.cpp can reference file.h with a #include "file.h" directive. However, it is common to find out libraries and other kinds of projects (like the linux kernel and freeRTOS) where all .h files are placed inside an include/ directory, while .cpp files remain in another directory. In those projects, .h files are also included with #include "file.h" instead of #include "include/file.h"

Why create an include/ directory in C and C++ projects?

删除回忆录丶 提交于 2021-02-05 19:34:22
问题 When I work on my personal C and C++ projects I usually put file.h and file.cpp in the same directory and then file.cpp can reference file.h with a #include "file.h" directive. However, it is common to find out libraries and other kinds of projects (like the linux kernel and freeRTOS) where all .h files are placed inside an include/ directory, while .cpp files remain in another directory. In those projects, .h files are also included with #include "file.h" instead of #include "include/file.h"

Preventing multiple #define when including headers

笑着哭i 提交于 2021-02-05 11:07:14
问题 coming from python and am a bit tripped up on what the proper approach to this is. I am trying to include this library in my project: https://github.com/nothings/stb/blob/master/stb_image.h to do so, i have to #define STB_IMAGE_IMPLEMENTATION exactly once before importing the file (as per that file's doc) This makes sense, where I am confused is, I have CLASS.h/cpp and in .h I define functions that use typedefs from that file, so I have #define STB_IMAGE_IMPLEMENTATION #include <stb_image.h>

Preventing multiple #define when including headers

佐手、 提交于 2021-02-05 11:06:29
问题 coming from python and am a bit tripped up on what the proper approach to this is. I am trying to include this library in my project: https://github.com/nothings/stb/blob/master/stb_image.h to do so, i have to #define STB_IMAGE_IMPLEMENTATION exactly once before importing the file (as per that file's doc) This makes sense, where I am confused is, I have CLASS.h/cpp and in .h I define functions that use typedefs from that file, so I have #define STB_IMAGE_IMPLEMENTATION #include <stb_image.h>

Preventing multiple #define when including headers

你说的曾经没有我的故事 提交于 2021-02-05 11:04:00
问题 coming from python and am a bit tripped up on what the proper approach to this is. I am trying to include this library in my project: https://github.com/nothings/stb/blob/master/stb_image.h to do so, i have to #define STB_IMAGE_IMPLEMENTATION exactly once before importing the file (as per that file's doc) This makes sense, where I am confused is, I have CLASS.h/cpp and in .h I define functions that use typedefs from that file, so I have #define STB_IMAGE_IMPLEMENTATION #include <stb_image.h>

Why has the <title>-tag to be placed into the <head> element?

泄露秘密 提交于 2021-02-05 09:54:50
问题 In the specific example, I got a website that is including many different content pages. Depending on the currently included page, the title is a different one. To achieve this, I got the following dynamic <title> almost at the end of the document . <title><?php echo $title1,' - ',$title2 ?> - *and some static text here*</title> $title2 is always in the directly included file and $title1 is even deeper. So far I didn't notice any kind of disadvantages. All titles are shown properly and all

Why has the <title>-tag to be placed into the <head> element?

北战南征 提交于 2021-02-05 09:53:31
问题 In the specific example, I got a website that is including many different content pages. Depending on the currently included page, the title is a different one. To achieve this, I got the following dynamic <title> almost at the end of the document . <title><?php echo $title1,' - ',$title2 ?> - *and some static text here*</title> $title2 is always in the directly included file and $title1 is even deeper. So far I didn't notice any kind of disadvantages. All titles are shown properly and all

Multiple definition of first defined here gcc

寵の児 提交于 2021-02-04 14:29:50
问题 I have these files consumer.cpp consumer.hpp defines.hpp main.cpp makefile producer.cpp producer.hpp here's the file defines.hpp #ifndef DEFINES_HPP #define DEFINES_HPP #include <cassert> #include <pthread.h> #include <queue> #include <stdlib.h> #include <string> #include <unistd.h> pthread_mutex_t set_queue_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t condition_var = PTHREAD_COND_INITIALIZER; std::queue<int> q; #endif // DEFINES_HPP This defines.hpp file is included in the producer.hpp

how to include a page in php

末鹿安然 提交于 2021-01-29 10:40:25
问题 I usually use this code below to include the page that I need into the body of my website to include the page when clicking on a link. <?php switch($_GET['page']){ case '1': if(file_exists('main.php')) { include_once('main.php'); break; } default: include_once('main.php'); break; } ?> but then I have to change this everytime i add a menu item by adding a case '2' ... etc and now my question can this be written shorter/dynamically so that i just can add a link without having to change the

Makefile to compile all src and generate static library

早过忘川 提交于 2021-01-29 08:31:54
问题 I've got a large-ish C project, and I want to generate a static library from all of my sources in the src/ file using the includes from my include/ path, and some other includes for my RTOS. I have a working set of steps in the line commands that work: gcc src/drivers/* src/packets/* (...more files) -c -I ./include -I ../SatelliteSim/Source/include/ -I ../SatelliteSim/Project/ -I ../SatelliteSim/Source/portable/GCC/POSIX/ -m32 -DDEBUG=1 -g -UUSE_STDIO -D__GCC_POSIX__=1 -pthread then, ar -rsc