Skip to content

Commit

Permalink
fix anon-struct usage that's a warning/error -Wnon-c-typedef-for-link…
Browse files Browse the repository at this point in the history
…age (#76610)

Summary:
X-link: pytorch/pytorch#76610

X-link: facebookincubator/gloo#328

X-link: facebookarchive/fbzmq#38

Pull Request resolved: facebook#137

Fix
  error: anonymous non-C-compatible type given name for linkage purposes by alias declaration; add a tag name here [-Werror,-Wnon-c-typedef-for-linkage]

Reviewed By: philippv

Differential Revision: D36043476

fbshipit-source-id: d26f1bf9952b4371d3d4901ae15a68af8fd4c2a1
  • Loading branch information
luciang authored and facebook-github-bot committed Apr 30, 2022
1 parent 8a55e16 commit 4cd5f1f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cachelib/compact_cache/CCacheDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ template <unsigned MaxSize>
struct VariableSizedValueDescriptor {
constexpr static bool kFixedSize = false;

using Value = struct {
struct Value {
char data[0];
// Data is here.
} __attribute__((__packed__));
Expand Down
4 changes: 2 additions & 2 deletions cachelib/compact_cache/CCacheFixedLruBucket.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ struct FixedLruBucket {

/** Type of the data stored in a bucket entry.
* This contains the key and the value (if any). */
using Entry = struct {
struct Entry {
Key key;
/* Expands to NoValue (size 0) if this cache does not store values */
Value val;
} __attribute__((__packed__));

/** Type of a bucket.
* Empty entry slots must be zeroed out to avoid spurious matches! */
using Bucket = struct {
struct Bucket {
Entry entries[kEntriesPerBucket];
} __attribute__((__packed__));

Expand Down
6 changes: 3 additions & 3 deletions cachelib/compact_cache/CCacheVariableLruBucket.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ struct VariableLruBucket {
constexpr static size_t kMaxEntries = std::numeric_limits<EntryNum>::max();

/** An entry header. */
using EntryHdr = struct {
struct EntryHdr {
Key key;
/* Size in bytes of the corresponding EntryData's data field. */
EntryDataSize dataSize;
Expand All @@ -140,7 +140,7 @@ struct VariableLruBucket {
EntryDataOffset dataOffset;
} __attribute__((__packed__));

using EntryData = struct {
struct EntryData {
/* Index of the corresponding EntryHdr header in the 'Entry
* Headers' section. This is a value between 0 and the number of entries
* in the bucket. */
Expand All @@ -155,7 +155,7 @@ struct VariableLruBucket {
constexpr static size_t kBucketDataSize =
kMaxValueSize + sizeof(EntryHdr) + sizeof(EntryData);

using Bucket = struct {
struct Bucket {
/* Number of entries in the bucket. */
EntryNum numEntries;
/* Size of the "Data" section.
Expand Down

0 comments on commit 4cd5f1f

Please sign in to comment.