Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [headers]

The tag has no usage guidance.

0
votes
1answer
80 views

Getting file format by checking file header [closed]

I'm writing a program, part of which consists of determining if a given file is a PNG. Knowing that a file doesn't have to be named with its respective filename extension to be of a certain type, I ...
4
votes
1answer
113 views

Should I specify my header include path in the source code, or as a project option?

Basically, I am asking, whether my code should say #include “../libs/src/my_lib.h” or #include “my_lib.h” with a complier option of -I ../libs/src/ I feel (reasonably strongly) that ...
3
votes
2answers
229 views

Include own header file first or last? Any technical reasons?

I was revisiting my question How can I prevent header hell?, when I noticed a comment which said A good technique for ensuring a header is independent is having a rule that the source file always ...
0
votes
2answers
53 views

Should I put request context in path or in headers?

I'm designing a system that will Act as proxy calling a service on a back-end in context of user and his session Manage sessions for users on multiple back-ends I will expose the system over HTTP. ...
1
vote
3answers
98 views

Detecting header inclusion chains and dependencies in C++

File Top.h #include <string> ...some code... File Bottom.h: #include "Top.h" void someFunction() { string s = new String(); ... } The Bottom.h does not contain an include for the string ...
2
votes
3answers
466 views

Is inlining almost all of my C++ application's methods a good or bad idea?

I am used to D coding and Python where the class definition also contains each method definiton. So it is my preferred style of coding. I abhor having to switch to the .cpp file and use that long ...
2
votes
3answers
1k views

Is it possible to create a C header file from a dynamic library?

Suppose I have a compiled dynamic library: .dll, .lib, .so etc. Is it (theoretically) possible to automatically create C header file for such a library? Is there an existing tool that does that? ...
2
votes
2answers
2k views

Why do we have to include multiple header files for a single library (the C standard library)?

I am not sure why there are so many header file for the C standard library (stdio.h, stdlib.h, math.h). How do these header files point to the same library? I guess I am a little bit confused about ...
9
votes
1answer
17k views

Where to place an API key: a custom HTTP header VS the Authorization header with a custom scheme

I'm designing a REST API using authorization/authentication via an API Key. I tried to figure out what is the best place for it and found out that many people suggest using a custom HTTP header such ...
5
votes
4answers
5k views

How to represent constants in UML class diagram?

I am working on developing a UML class diagram from C++ code. I have a classless header file that is basically a definitions file (it has structs, enums and defined constants). I know how to ...
1
vote
1answer
60 views

Should I doxygenate implementation files in a library of mine, in addition to the headers?

I'm in the process of writing Doxygen comments for this library of mine; it's a header-mostly C++ library, but it does have some code which gets linked rather than included. For that code, which has ....
5
votes
4answers
909 views

What are the benefits of using meta tag/JavaScript redirection over HTTP header redirection?

Upon inspecting Twitter's URL shortening service http://t.co, I noticed that, instead of redirecting to the goal URL using a Location HTTP header and a 3xx HTTP status code, it redirects using the ...
43
votes
7answers
13k views

How can I prevent header hell?

We are starting a new project, from scratch. About eight developers, a dozen or so subsystems, each with four or five source files. What can we do to prevent “header hell”, AKA “spaghetti headers”? ...
3
votes
2answers
130 views

If no extra #include required, is “this method doesn't suppose to be changed” a good reason to define a method in .h?

Suppose I am developing mobile applications using C++, and I found some methods are not suppose to change once written, for example: class MyClass{ public: float kmHrToms(float kmHr){ ...
1
vote
2answers
286 views

What is the proper way to implement an abstract data type in C?

In his book Patterns in C, Adam Petersen describes using a pointer to a struct, which is declared in a header file, to create a first-class abstract data-type: /* Customer.h */ /* A pointer to an ...
3
votes
3answers
829 views

namespaces and header guards with naming conflicts

C++ has namespaces to prevent collisions of things with the same name. Header guards serve a different purpose. They prevent includeing the same header twice. However, they can suffer from the same ...
1
vote
0answers
277 views

How are HTML files with binary headers interpreted? [closed]

I recently got an inexpensive phone with minimal browser support i.e. no javascript and on a small screen. Wanting to make the most of my device, I decided I would load some ebooks onto my device ...
4
votes
5answers
3k views

Should empty method be placed in .h or .cpp?

for example, I have A.h, which has a class A with some empty methods: class A : public B{ public: A(){ } virtual void b(){ } ~A(){ } //other methods }; should I move ...
2
votes
1answer
452 views

Configuration related defines in public header?

Suppose you're building some library, C or C++ doesn't really matter for this question, IMO. The features (or implementation thereof) depend on capabilities of the target system. A simple, probably ...
2
votes
2answers
712 views

Should we “balance” the amount of codes between .h and .cpp?

As far as I know, .cpp usually contains far more codes than .h, mainly because .cpp contain implementation details of functions instead of just one line of class member/method definition. Here comes ...
2
votes
2answers
886 views

Code size overhead by including unnecessarily extra header files

I have a program which includes lots of header files but it do not uses all the header files. I have removed some of them although it is working fine. I did not notice any changes in the performance. ...
4
votes
1answer
978 views

Are include guards necessary if headers only contain declarations?

Consider the following assumptions about C programming (some of which go too far, I confess): Putting any variable definitions in a header file is incorrect, because each translation unit creates its ...
2
votes
2answers
193 views

Fully Specifying #includes

I'm very fastidious about code. When I remove functionality from a file I remove the cooresponding #includes. I've hit several errors where I would remove a #include from a header, and another file ...
8
votes
3answers
3k views

C++ Header files design : just like defining an API?

I'm kind of new to large scale software development in C++, and I was wondering on the design side of things. I was reading this question, and I thought that, overall, once we get past constant ...
3
votes
0answers
139 views

Should the order of definitions correspond to the order of declarations in header/source files? [closed]

If my header looks like this: class foo { public: foo(); ~foo(); QString b(); QString c(); QString a(); void setB(QString s); void setC(QString s); void setA(...
3
votes
2answers
3k views

REST API paging via headers

Let's say I have REST API which provides me list of something and I want to implement paging support - possibility to tell "give me records 20-29 (page 3)". Currently, I don't care about ...
-1
votes
2answers
454 views

If I #include a file, do I need to have a valid path to any headers #included in the included file [closed]

For example, if I have created a library, libcommon, which uses some other custom, but widely used library in a specific field (some_other), like this: libcommon.h #ifndef LIBCOMMON_H #define ...
3
votes
1answer
1k views

C Module - Where to put prototypes and definitions that do not belong to the public interface?

Since I am mainly an Electrical Engineer, forgive me if I am somewhat off with some terminology. I am currently programming a display driver/interface module. And like so many times before, I have ...
2
votes
3answers
3k views

In C++, should I ever declare a local variable in the corresponding header?

So for example, I create a class with two functions: foo.h class foo { public: foo(); void bar(); void ey(); bool m_memberBool; bool localBool; // ??? Should I put this here? }; ...
1
vote
4answers
1k views

cpp and h/hpp #include: “why” question

Why does the source include a header and not also the other way around? I googled it but only found questions regarding the use of header files, how to include them but nowhere to say why it is like ...
5
votes
1answer
2k views

Using macros to protect assignment to global variables

Because there is no language feature in C to protect assignment to global variables would you recommend doing something like this? Take this example: We have a module with the header file called ...
35
votes
8answers
11k views

Is it good practice to rely on headers being included transitively?

I'm cleaning up the includes in a C++ project I'm working on, and I keep wondering whether or not I should explicitly include all headers used directly in a particular file, or whether I should only ...
0
votes
0answers
491 views

Consistent header HTML across multiple sites

We've got several sites. Some are HTML/Angular, some are built on a CMS, some are built on other code. What we'd like to do is have a consistent header experience for each site. I'm trying to figure ...
18
votes
7answers
36k views

Why do we need to include the .h while everything works when including only the .cpp file?

Why do we need to include both the .h and .cpp files , while we can make it works with making just a .cpp file and then including it . For example, Creating a file.h containing declarations, then ...
2
votes
1answer
2k views

Splitting and hiding headers in a static library

I am writing a static library for C/C++ (personal project). As my headers became rather large, I thought that splitting my headers would be a good idea. Right now a header looks like this: MainClass....
6
votes
2answers
4k views

Why are header files bad design? [duplicate]

this says header files are bad design, but I don't know why. The answers specified there are about the inefficiency of header file when building. Why it is bad design is not really touched upon. As ...
0
votes
1answer
907 views

How to POST CSV with XMLHttpRequest

I would like to send a CSV file via POST in a XMLHttpRequest, but I am unsure of two things. First is there anything to distinguish a CSV file from a string split up by comma's? And what sort of ...
0
votes
1answer
66 views

How to use specific Request Header [closed]

I am learning how to work with XMLHttpRequests. I know that request.setRequestHeader() is an important factor. I just don't understand why. It took me a while but I have at least found a list of ...
1
vote
3answers
235 views

Requiring a specific order of compilaiton

When designing a compiled programming language, is it a bad idea to require a specific order of compilation of separate units, according to their dependencies? To illustrate what I mean, consider C. ...
3
votes
1answer
466 views

PHP high traffic default page

I have a php website that will be experiencing high levels of traffic in a few weeks. We scaled the servers to accept the traffic, but want some sort of fallback page in the event that something ...
9
votes
3answers
29k views

Is it safe to transmit access tokens via HTTP headers?

It's the first RESTful web service and I am concerned about security issues. Is it safe to transmit my access token via HTTP headers? For example: POST /v1/i/resource HTTP/1.1 Content-Type: ...
-1
votes
1answer
391 views

Take dynamic PHP array, package up as separate files inside a single zip file

I have this dynamic data in PHP, but for each array record, I want to allow a downloadable option to save a zip archive of all records (each as a separate file). These are actually DNS zone records ...
9
votes
2answers
1k views

Updating copyright headers each new year just because Jan 1st has passed? [duplicate]

I've seen some projects that - with each new year - start to change all files in their source-tree to update the copyright year. Isn't this just pushing hot air on a level of magnitude? AFAIK: ...
7
votes
1answer
367 views

Web revisioning and the Accept-Datetime header

I have been in the process of generating documentation for an upcoming project. One of the features of the data available in this project is that it will be revisioned (or at least large parts of it ...
9
votes
2answers
14k views

Custom use of Authorization header in a REST API

I'm building a REST api where clients are authenticated using client certificates. A client in this case is not an individual user, but some sort of a presentation layer. Users are authenticated using ...
61
votes
5answers
127k views

What should and what shouldn't be in a header file? [closed]

What things should absolutely never be included in a header file? If for example I'm working with a documented industry standard format that has a lot of constants, is it a good practice to define ...
3
votes
1answer
207 views

Handling bugs, quirks, or annoyances in vendor-supplied headers

If the header file supplied by a vendor of something with whom one's code must interact is deficient in some way, in what cases is it better to: Work around the header's deficiencies in the main code ...
2
votes
4answers
1k views

Common header file for C++ and JavaScipt

I have an app that runs a C++ server backend and Javascript on the client. I would like to define certain strings once only, for both pieces of code. For example, I might have a CSS class "row-hover"...
1
vote
1answer
158 views

How do I parse a header with two different version [ID3] avoiding code duplication?

I really hope you can give me some interesting viewpoints for my situation, because I am not satisfied with my current approach. I am writing an MP3 parser, starting with an ID3v2 parser. Right now ...
7
votes
2answers
2k views

What's special in July 26th and why is it used in examples for Expires header so often?

I've noticed that July 26th (my birthday) is used really often in various PHP examples related to preventing http caching using Expires header, like: https://stackoverflow.com/questions/12398714/...