Skip to content

Commit 22190c9

Browse files
DOC-4997 fixed misleading header advice
1 parent 41faa20 commit 22190c9

File tree

5 files changed

+22
-55
lines changed

5 files changed

+22
-55
lines changed

content/develop/clients/hiredis/_index.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ Then, in a terminal, go into the `hiredis` folder and run the `make` command to
3030
the dynamically-loaded library for `hiredis` (this has the name `libhiredis.dylib` on
3131
MacOS and `libhiredis.so` on Linux). You can copy this library to your
3232
project folder or run `sudo make install` to install it to `/usr/local/lib`.
33-
You should also copy the header files `hiredis.h`, `alloc.h`, `read.h`, and
34-
`sds.h` to your project.
3533

3634
## Connect and test
3735

@@ -43,7 +41,7 @@ connection. An explanation of the code follows the example.
4341
```c
4442
#include <stdio.h>
4543

46-
#include "hiredis.h"
44+
#include <hiredis/hiredis.h>
4745

4846
int main() {
4947
// The `redisContext` type represents the connection
@@ -81,8 +79,9 @@ int main() {
8179

8280
For a real project, you would build your code with a makefile, but for
8381
this simple test, you can just place it in a file called `main.c` and
84-
build it with the following command (assuming you used `make install` to
85-
install the `libhiredis` library):
82+
build it with the following command. (If you didn't install `hiredis`
83+
using `make install`, then you should also use the `-I` option to
84+
specify the folder that contains the `hiredis` headers.)
8685

8786
```bash
8887
cc main.c -L/usr/local/lib -lhiredis
@@ -123,11 +122,7 @@ to prevent errors.
123122
The [`hiredis`](https://github.com/redis/hiredis) Github repository contains
124123
examples and details that may be useful if you are using `hiredis` to
125124
implement a higher-level client for another programming language. There are
126-
also examples showing how to use `hiredis` from a
127-
[C++ application](https://github.com/redis/hiredis/blob/master/examples/example-qt.cpp)
128-
created with [Qt](https://www.qt.io/) and how to use the
129-
[asynchronous API](https://github.com/redis/hiredis?tab=readme-ov-file#asynchronous-api)
130-
with the [libev](https://software.schmorp.de/pkg/libev.html) and
131-
[libevent](https://libevent.org/) libraries.
125+
also examples showing how to use `hiredis` adapter headers to integrate with
126+
various event handling frameworks.
132127

133128
See the other pages in this section for more information and examples.

content/develop/clients/hiredis/connect.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ and port as its arguments, and returns a context object.
2525
```c
2626
#include <stdio.h>
2727

28-
#include "hiredis.h"
28+
#include <hiredis/hiredis.h>
2929
.
3030
.
3131
.
@@ -72,13 +72,14 @@ It lets you supply callbacks to respond when a connection is successful
7272
or to handle any errors that may occur.
7373
7474
The following code creates an asynchronous connection and
75-
sets the context callbacks:
75+
sets the context callbacks. Note that you must also include the
76+
`async.h` header to access the asynchronous API.
7677
7778
```c
7879
#include <stdio.h>
7980
80-
#include "hiredis.h"
81-
#include "async.h"
81+
#include <hiredis/hiredis.h>
82+
#include <hiredis/async.h>
8283
.
8384
.
8485
.

content/develop/clients/hiredis/int-examples/libevent-integration.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,6 @@ cc main.c -L/usr/local/lib -lhiredis -levent
4444
See [Build and install]({{< relref "/develop/clients/hiredis#build-and-install" >}})
4545
to learn how to build `hiredis`, if you have not already done so.
4646

47-
Add the following header files from the `hiredis` folder to your project folder:
48-
49-
- `hiredis.h`
50-
- `async.h`
51-
- `adapters/libevent.h`
52-
53-
You should include the `libevent.h` file in a folder called `adapters` but you
54-
don't need the other headers in the original `adapters` folder for this
55-
example.
56-
5747
Now, add the following code in `main.c`. An explanation follows the
5848
code example:
5949

@@ -63,9 +53,9 @@ code example:
6353
#include <string.h>
6454
#include <signal.h>
6555

66-
#include "hiredis.h"
67-
#include "async.h"
68-
#include "adapters/libevent.h"
56+
#include <hiredis/hiredis.h>
57+
#include <hiredis/async.h>
58+
#include <hiredis/adapters/libevent.h>
6959

7060
// Callback for the `GET` command.
7161
void getCallback(redisAsyncContext *c, void *r, void *privdata) {

content/develop/clients/hiredis/int-examples/qt-integration.md

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,7 @@ it doesn't do anything useful at this stage.
4242

4343
Build `hiredis` if you have not already done so (see
4444
[Build and install]({{< relref "/develop/clients/hiredis#build-and-install" >}})
45-
for more information). Copy the following files from the `hiredis` folder into
46-
the Header files section of your Qt project:
47-
48-
- `hiredis.h`
49-
- `async.h`
50-
- `alloc.h`
51-
- `read.h`
52-
- `sds.h`
53-
- `adapters/qt.h`
54-
55-
In `qt.h`, edit the line near the top of the file that reads
56-
57-
```c
58-
#include "../async.h"
59-
```
60-
61-
to
62-
63-
```c
64-
#include "async.h"
65-
```
66-
67-
You must do this because `qt.h` is in the same enclosing folder as `async.h` for
68-
this project.
45+
for more information).
6946

7047
You should also make the `libhiredis` library available to the project. For example,
7148
if you have used the default option of [`cmake`](https://cmake.org/) as the project
@@ -106,9 +83,9 @@ An explanation follows the code.
10683

10784
#include <QObject>
10885

109-
#include "hiredis.h"
110-
#include "async.h"
111-
#include "qt.h"
86+
#include <hiredis/hiredis.h>
87+
#include <hiredis/async.h>
88+
#include <hiredis/adapters/qt.h>
11289

11390

11491
class RedisExample : public QObject

content/develop/clients/hiredis/issue-commands.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ Use the `redisAsyncCommand()` and `redisAsyncCommandArgv()`
122122
functions to send commands to the server asynchronously:
123123

124124
```c
125+
#include <hiredis/async.h>
126+
.
127+
.
128+
.
125129
int redisAsyncCommand(
126130
redisAsyncContext *ac, redisCallbackFn *fn, void *privdata,
127131
const char *format, ...);

0 commit comments

Comments
 (0)