Skip to content

Commit

Permalink
Suppress const warning for Windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
etan-status committed Aug 9, 2024
1 parent 99b9c35 commit 58258a8
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions blscurve/blst/blst_min_pubkey_sig_core.nim
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,21 @@ func update*[T: char|byte](
aug = ""
)

template ignoringIncompatiblePointerTypes(body: untyped): untyped =
# Nim does not support annotating pointer destinations with C `const`
{.emit: """
#ifdef __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#endif
""".}
body
{.emit: """
#ifdef __clang__
#pragma GCC diagnostic pop
#endif
""".}

func combine*(
secureRandomBytes: array[32, byte],
publicKeys: openArray[PublicKey],
Expand Down Expand Up @@ -620,23 +635,29 @@ func combine*(
signature {.noinit.}: Signature
block:
var combinedPublicKey {.noinit.}: AggregatePublicKey
blst_p1s_mult_pippenger(
toCV(combinedPublicKey, cblst_p1),
publicKeysRef[0].unsafeAddr,
numEntries,
scalarsRef[0].unsafeAddr,
nbits = 64,
scratch[0].addr)
ignoringIncompatiblePointerTypes:
# expected 'const blst_p1_affine * const*'
# but argument is of type 'blst_p1_affine **'
blst_p1s_mult_pippenger(
toCV(combinedPublicKey, cblst_p1),
publicKeysRef[0].unsafeAddr,
numEntries,
scalarsRef[0].unsafeAddr,
nbits = 64,
scratch[0].addr)
publicKey.finish combinedPublicKey
block:
var combinedSignature {.noinit.}: AggregateSignature
blst_p2s_mult_pippenger(
toCV(combinedSignature, cblst_p2),
signaturesRef[0].unsafeAddr,
numEntries,
scalarsRef[0].unsafeAddr,
nbits = 64,
scratch[0].addr)
ignoringIncompatiblePointerTypes:
# expected 'const blst_p2_affine * const*'
# but argument is of type 'blst_p2_affine **'
blst_p2s_mult_pippenger(
toCV(combinedSignature, cblst_p2),
signaturesRef[0].unsafeAddr,
numEntries,
scalarsRef[0].unsafeAddr,
nbits = 64,
scratch[0].addr)
signature.finish combinedSignature
(publicKey, signature)

Expand Down

0 comments on commit 58258a8

Please sign in to comment.