From 73cc43f212eebcfaa9385a229e301d87463169d6 Mon Sep 17 00:00:00 2001 From: rad9800 <105589633+rad9800@users.noreply.github.com> Date: Tue, 12 Jul 2022 15:02:32 +0100 Subject: [PATCH] Update entropy.cpp --- entropy.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/entropy.cpp b/entropy.cpp index 2644e0c..1cf3924 100644 --- a/entropy.cpp +++ b/entropy.cpp @@ -29,7 +29,14 @@ struct E { T array[N]; }; -constexpr auto e = E<4000, long long, 0>(); +// https://docs.microsoft.com/en-us/cpp/build/reference/section-specify-section-attributes?view=msvc-170 +#pragma code_seg(".text") +__declspec(allocate(".text")) +constexpr auto e = E<2500, long long, 1>(); + +#pragma code_seg(".data") +__declspec(allocate(".data")) +constexpr auto e2 = E<2500, long long, 1>(); /*++ @@ -72,6 +79,9 @@ int main() { // get optimized out by the compiler for (auto x : e.array) total += x; - - return total; // prevent compiler optimizing it out on /O1 /O2 + + for (auto x : e2.array) + total += x; + + return total; }