Skip to content

Commit eebbab3

Browse files
Fixed compilation error when including in C++ units. (#5)
For C++ (and atleast g++), extern "C" (aka. PB_EXPORT for us) must be the first thing in a (function) declaration. Thus, just reorder things - swap all PB_WARN_UNUSED_RESULT with PB_EXPORT to resolve this issue.
1 parent 61b3f22 commit eebbab3

File tree

11 files changed

+86
-86
lines changed

11 files changed

+86
-86
lines changed

include/protobluff/core/buffer.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,30 +44,30 @@ typedef struct pb_buffer_t {
4444
* Interface
4545
* ------------------------------------------------------------------------- */
4646

47-
PB_WARN_UNUSED_RESULT
48-
PB_EXPORT pb_buffer_t
47+
PB_EXPORT PB_WARN_UNUSED_RESULT
48+
pb_buffer_t
4949
pb_buffer_create(
5050
const uint8_t data[], /* Raw data */
5151
size_t size); /* Raw data size */
5252

53-
PB_WARN_UNUSED_RESULT
54-
PB_EXPORT pb_buffer_t
53+
PB_EXPORT PB_WARN_UNUSED_RESULT
54+
pb_buffer_t
5555
pb_buffer_create_with_allocator(
5656
pb_allocator_t *allocator, /* Allocator */
5757
const uint8_t data[], /* Raw data */
5858
size_t size); /* Raw data size */
5959

60-
PB_WARN_UNUSED_RESULT
61-
PB_EXPORT pb_buffer_t
60+
PB_EXPORT PB_WARN_UNUSED_RESULT
61+
pb_buffer_t
6262
pb_buffer_create_empty(void);
6363

64-
PB_WARN_UNUSED_RESULT
65-
PB_EXPORT pb_buffer_t
64+
PB_EXPORT PB_WARN_UNUSED_RESULT
65+
pb_buffer_t
6666
pb_buffer_create_empty_with_allocator(
6767
pb_allocator_t *allocator); /* Allocator */
6868

69-
PB_WARN_UNUSED_RESULT
70-
PB_EXPORT pb_buffer_t
69+
PB_EXPORT PB_WARN_UNUSED_RESULT
70+
pb_buffer_t
7171
pb_buffer_create_zero_copy(
7272
uint8_t data[], /* Raw data */
7373
size_t size); /* Raw data size */

include/protobluff/core/decoder.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ typedef struct pb_decoder_t {
5151
* Interface
5252
* ------------------------------------------------------------------------- */
5353

54-
PB_WARN_UNUSED_RESULT
55-
PB_EXPORT pb_decoder_t
54+
PB_EXPORT PB_WARN_UNUSED_RESULT
55+
pb_decoder_t
5656
pb_decoder_create(
5757
const pb_descriptor_t
5858
*descriptor, /* Descriptor */
@@ -62,8 +62,8 @@ PB_EXPORT void
6262
pb_decoder_destroy(
6363
pb_decoder_t *decoder); /* Decoder */
6464

65-
PB_WARN_UNUSED_RESULT
66-
PB_EXPORT pb_error_t
65+
PB_EXPORT PB_WARN_UNUSED_RESULT
66+
pb_error_t
6767
pb_decoder_decode(
6868
const pb_decoder_t *decoder, /* Decoder */
6969
pb_decoder_handler_f handler, /* Handler */

include/protobluff/core/encoder.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ typedef struct pb_encoder_t {
4545
* Interface
4646
* ------------------------------------------------------------------------- */
4747

48-
PB_WARN_UNUSED_RESULT
49-
PB_EXPORT pb_encoder_t
48+
PB_EXPORT PB_WARN_UNUSED_RESULT
49+
pb_encoder_t
5050
pb_encoder_create(
5151
const pb_descriptor_t *descriptor); /* Descriptor */
5252

53-
PB_WARN_UNUSED_RESULT
54-
PB_EXPORT pb_encoder_t
53+
PB_EXPORT PB_WARN_UNUSED_RESULT
54+
pb_encoder_t
5555
pb_encoder_create_with_allocator(
5656
pb_allocator_t *allocator, /* Allocator */
5757
const pb_descriptor_t *descriptor); /* Descriptor */
@@ -60,8 +60,8 @@ PB_EXPORT void
6060
pb_encoder_destroy(
6161
pb_encoder_t *encoder); /* Encoder */
6262

63-
PB_WARN_UNUSED_RESULT
64-
PB_EXPORT pb_error_t
63+
PB_EXPORT PB_WARN_UNUSED_RESULT
64+
pb_error_t
6565
pb_encoder_encode(
6666
pb_encoder_t *encoder, /* Encoder */
6767
pb_tag_t tag, /* Tag */

include/protobluff/message/cursor.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ typedef struct pb_cursor_t {
5151
* Interface
5252
* ------------------------------------------------------------------------- */
5353

54-
PB_WARN_UNUSED_RESULT
55-
PB_EXPORT pb_cursor_t
54+
PB_EXPORT PB_WARN_UNUSED_RESULT
55+
pb_cursor_t
5656
pb_cursor_create(
5757
pb_message_t *message, /* Message */
5858
pb_tag_t tag); /* Tag */
5959

60-
PB_WARN_UNUSED_RESULT
61-
PB_EXPORT pb_cursor_t
60+
PB_EXPORT PB_WARN_UNUSED_RESULT
61+
pb_cursor_t
6262
pb_cursor_create_nested(
6363
pb_message_t *message, /* Message */
6464
const pb_tag_t tags[], /* Tags */
@@ -90,20 +90,20 @@ pb_cursor_match(
9090
pb_cursor_t *cursor, /* Cursor */
9191
const void *value); /* Pointer holding value */
9292

93-
PB_WARN_UNUSED_RESULT
94-
PB_EXPORT pb_error_t
93+
PB_EXPORT PB_WARN_UNUSED_RESULT
94+
pb_error_t
9595
pb_cursor_get(
9696
pb_cursor_t *cursor, /* Cursor */
9797
void *value); /* Pointer receiving value */
9898

99-
PB_WARN_UNUSED_RESULT
100-
PB_EXPORT pb_error_t
99+
PB_EXPORT PB_WARN_UNUSED_RESULT
100+
pb_error_t
101101
pb_cursor_put(
102102
pb_cursor_t *cursor, /* Cursor */
103103
const void *value); /* Pointer holding value */
104104

105-
PB_WARN_UNUSED_RESULT
106-
PB_EXPORT pb_error_t
105+
PB_EXPORT PB_WARN_UNUSED_RESULT
106+
pb_error_t
107107
pb_cursor_erase(
108108
pb_cursor_t *cursor); /* Cursor */
109109

include/protobluff/message/field.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,21 @@ typedef struct pb_field_t {
5151
* Interface
5252
* ------------------------------------------------------------------------- */
5353

54-
PB_WARN_UNUSED_RESULT
55-
PB_EXPORT pb_field_t
54+
PB_EXPORT PB_WARN_UNUSED_RESULT
55+
pb_field_t
5656
pb_field_create(
5757
struct pb_message_t *message, /* Message */
5858
pb_tag_t tag); /* Tag */
5959

60-
PB_WARN_UNUSED_RESULT
61-
PB_EXPORT pb_field_t
60+
PB_EXPORT PB_WARN_UNUSED_RESULT
61+
pb_field_t
6262
pb_field_create_nested(
6363
struct pb_message_t *message, /* Message */
6464
const pb_tag_t tags[], /* Tags */
6565
size_t size); /* Tag count */
6666

67-
PB_WARN_UNUSED_RESULT
68-
PB_EXPORT pb_field_t
67+
PB_EXPORT PB_WARN_UNUSED_RESULT
68+
pb_field_t
6969
pb_field_create_from_cursor(
7070
struct pb_cursor_t *cursor); /* Cursor */
7171

@@ -78,20 +78,20 @@ pb_field_match(
7878
pb_field_t *field, /* Field */
7979
const void *value); /* Pointer holding value */
8080

81-
PB_WARN_UNUSED_RESULT
82-
PB_EXPORT pb_error_t
81+
PB_EXPORT PB_WARN_UNUSED_RESULT
82+
pb_error_t
8383
pb_field_get(
8484
pb_field_t *field, /* Field */
8585
void *value); /* Pointer receiving value */
8686

87-
PB_WARN_UNUSED_RESULT
88-
PB_EXPORT pb_error_t
87+
PB_EXPORT PB_WARN_UNUSED_RESULT
88+
pb_error_t
8989
pb_field_put(
9090
pb_field_t *field, /* Field */
9191
const void *value); /* Pointer holding value */
9292

93-
PB_WARN_UNUSED_RESULT
94-
PB_EXPORT pb_error_t
93+
PB_EXPORT PB_WARN_UNUSED_RESULT
94+
pb_error_t
9595
pb_field_clear(
9696
pb_field_t *field); /* Field */
9797

include/protobluff/message/journal.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,30 +53,30 @@ typedef struct pb_journal_t {
5353
* Interface
5454
* ------------------------------------------------------------------------- */
5555

56-
PB_WARN_UNUSED_RESULT
57-
PB_EXPORT pb_journal_t
56+
PB_EXPORT PB_WARN_UNUSED_RESULT
57+
pb_journal_t
5858
pb_journal_create(
5959
const uint8_t data[], /* Raw data */
6060
size_t size); /* Raw data size */
6161

62-
PB_WARN_UNUSED_RESULT
63-
PB_EXPORT pb_journal_t
62+
PB_EXPORT PB_WARN_UNUSED_RESULT
63+
pb_journal_t
6464
pb_journal_create_with_allocator(
6565
pb_allocator_t *allocator, /* Allocator */
6666
const uint8_t data[], /* Raw data */
6767
size_t size); /* Raw data size */
6868

69-
PB_WARN_UNUSED_RESULT
70-
PB_EXPORT pb_journal_t
69+
PB_EXPORT PB_WARN_UNUSED_RESULT
70+
pb_journal_t
7171
pb_journal_create_empty(void);
7272

73-
PB_WARN_UNUSED_RESULT
74-
PB_EXPORT pb_journal_t
73+
PB_EXPORT PB_WARN_UNUSED_RESULT
74+
pb_journal_t
7575
pb_journal_create_empty_with_allocator(
7676
pb_allocator_t *allocator); /* Allocator */
7777

78-
PB_WARN_UNUSED_RESULT
79-
PB_EXPORT pb_journal_t
78+
PB_EXPORT PB_WARN_UNUSED_RESULT
79+
pb_journal_t
8080
pb_journal_create_zero_copy(
8181
uint8_t data[], /* Raw data */
8282
size_t size); /* Raw data size */

include/protobluff/message/message.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,32 +51,32 @@ typedef struct pb_message_t {
5151
* Interface
5252
* ------------------------------------------------------------------------- */
5353

54-
PB_WARN_UNUSED_RESULT
55-
PB_EXPORT pb_message_t
54+
PB_EXPORT PB_WARN_UNUSED_RESULT
55+
pb_message_t
5656
pb_message_create(
5757
const pb_descriptor_t *descriptor, /* Descriptor */
5858
pb_journal_t *journal); /* Journal */
5959

60-
PB_WARN_UNUSED_RESULT
61-
PB_EXPORT pb_message_t
60+
PB_EXPORT PB_WARN_UNUSED_RESULT
61+
pb_message_t
6262
pb_message_create_within(
6363
pb_message_t *message, /* Message */
6464
pb_tag_t tag); /* Tag */
6565

66-
PB_WARN_UNUSED_RESULT
67-
PB_EXPORT pb_message_t
66+
PB_EXPORT PB_WARN_UNUSED_RESULT
67+
pb_message_t
6868
pb_message_create_nested(
6969
pb_message_t *message, /* Message */
7070
const pb_tag_t tags[], /* Tags */
7171
size_t size); /* Tag count */
7272

73-
PB_WARN_UNUSED_RESULT
74-
PB_EXPORT pb_message_t
73+
PB_EXPORT PB_WARN_UNUSED_RESULT
74+
pb_message_t
7575
pb_message_create_from_cursor(
7676
struct pb_cursor_t *cursor); /* Cursor */
7777

78-
PB_WARN_UNUSED_RESULT
79-
PB_EXPORT pb_message_t
78+
PB_EXPORT PB_WARN_UNUSED_RESULT
79+
pb_message_t
8080
pb_message_create_from_field(
8181
const pb_descriptor_t *descriptor, /* Descriptor */
8282
struct pb_field_t *field); /* Bytes field */
@@ -100,28 +100,28 @@ pb_message_match(
100100
pb_tag_t tag, /* Tag */
101101
const void *value); /* Pointer holding value */
102102

103-
PB_WARN_UNUSED_RESULT
104-
PB_EXPORT pb_error_t
103+
PB_EXPORT PB_WARN_UNUSED_RESULT
104+
pb_error_t
105105
pb_message_get(
106106
pb_message_t *message, /* Message */
107107
pb_tag_t tag, /* Tag */
108108
void *value); /* Pointer receiving value */
109109

110-
PB_WARN_UNUSED_RESULT
111-
PB_EXPORT pb_error_t
110+
PB_EXPORT PB_WARN_UNUSED_RESULT
111+
pb_error_t
112112
pb_message_put(
113113
pb_message_t *message, /* Message */
114114
pb_tag_t tag, /* Tag */
115115
const void *value); /* Pointer holding value */
116116

117-
PB_WARN_UNUSED_RESULT
118-
PB_EXPORT pb_error_t
117+
PB_EXPORT PB_WARN_UNUSED_RESULT
118+
pb_error_t
119119
pb_message_erase(
120120
pb_message_t *message, /* Message */
121121
pb_tag_t tag); /* Tag */
122122

123-
PB_WARN_UNUSED_RESULT
124-
PB_EXPORT pb_error_t
123+
PB_EXPORT PB_WARN_UNUSED_RESULT
124+
pb_error_t
125125
pb_message_clear(
126126
pb_message_t *message); /* Message */
127127

include/protobluff/message/nested.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,24 @@ pb_message_nested_match(
4545
size_t size, /* Tag count */
4646
const void *value); /* Pointer holding value */
4747

48-
PB_WARN_UNUSED_RESULT
49-
PB_EXPORT pb_error_t
48+
PB_EXPORT PB_WARN_UNUSED_RESULT
49+
pb_error_t
5050
pb_message_nested_get(
5151
pb_message_t *message, /* Message */
5252
const pb_tag_t tags[], /* Tags */
5353
size_t size, /* Tag count */
5454
void *value); /* Pointer receiving value */
5555

56-
PB_WARN_UNUSED_RESULT
57-
PB_EXPORT pb_error_t
56+
PB_EXPORT PB_WARN_UNUSED_RESULT
57+
pb_error_t
5858
pb_message_nested_put(
5959
pb_message_t *message, /* Message */
6060
const pb_tag_t tags[], /* Tags */
6161
size_t size, /* Tag count */
6262
const void *value); /* Pointer holding value */
6363

64-
PB_WARN_UNUSED_RESULT
65-
PB_EXPORT pb_error_t
64+
PB_EXPORT PB_WARN_UNUSED_RESULT
65+
pb_error_t
6666
pb_message_nested_erase(
6767
pb_message_t *message, /* Message */
6868
const pb_tag_t tags[], /* Tags */

include/protobluff/message/oneof.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ typedef struct pb_oneof_t {
4949
* Interface
5050
* ------------------------------------------------------------------------- */
5151

52-
PB_WARN_UNUSED_RESULT
53-
PB_EXPORT pb_oneof_t
52+
PB_EXPORT PB_WARN_UNUSED_RESULT
53+
pb_oneof_t
5454
pb_oneof_create(
5555
const pb_oneof_descriptor_t
5656
*descriptor, /* Oneof descriptor */
@@ -64,8 +64,8 @@ PB_EXPORT pb_tag_t
6464
pb_oneof_case(
6565
pb_oneof_t *oneof); /* Oneof */
6666

67-
PB_WARN_UNUSED_RESULT
68-
PB_EXPORT pb_error_t
67+
PB_EXPORT PB_WARN_UNUSED_RESULT
68+
pb_error_t
6969
pb_oneof_clear(
7070
pb_oneof_t *oneof); /* Oneof */
7171

include/protobluff/util/chunk_allocator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
* Interface
3333
* ------------------------------------------------------------------------- */
3434

35-
PB_WARN_UNUSED_RESULT
36-
PB_EXPORT pb_allocator_t
35+
PB_EXPORT PB_WARN_UNUSED_RESULT
36+
pb_allocator_t
3737
pb_chunk_allocator_create();
3838

39-
PB_WARN_UNUSED_RESULT
40-
PB_EXPORT pb_allocator_t
39+
PB_EXPORT PB_WARN_UNUSED_RESULT
40+
pb_allocator_t
4141
pb_chunk_allocator_create_with_capacity(
4242
size_t capacity); /* Chunk capacity */
4343

0 commit comments

Comments
 (0)