Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6927829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:06:21+00:00 2026-05-27T11:06:21+00:00

in my c++ dll application I want to define a variable byte, which its

  • 0

in my c++ dll application I want to define a variable byte, which its value will be initiate in the dll init with random value and then it will hold the same value during the dll live.

  1. what is the definition for this variable?
  2. where should I initiate it in code (where is the init of library)

thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:06:22+00:00Added an answer on May 27, 2026 at 11:06 am
    1. Either static class member (accessible from anywhere) or file-scope static or anonymous namespace member (accessible from just that compilation unit).

      1. Static class member:

        in .h:

        class Foo {
            //...
            static char random_byte;
            //...
        };
        

        in .cpp:

        char Foo::random_byte = init_random_byte();
        
      2. File-scoped static:

        static char random_byte = init_random_byte();
        
      3. Anonymous namespace member:

        namespace {
            //...
            char random_byte = init_random_byte();
            //...
        }
        
    2. In C++ the initializer can be arbitrary expression and the runtime will make sure to run it before main() function; in case of shared library when it’s loaded. Just remember, that these initialization expressions are called in order of appearance within compilation unit (single .cpp), but initialization from different compilation units will run at random order, so make sure they don’t depend on each other. They can depend on variables initialized to constants being already initialized.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a DLL that another application would use. I want to store
In short: I want to monitor selected calls from an application to a DLL.
I am using .dll reference to my application. i want to unload the .dll
I have DLL and application that will call some function in this dll. For
I have application which needs to use a dll (also written by me) which
I created my first Silverlight application. In the client project, I want to define
I want to reference a win32 dll from my Qt application. I've added the
Basically I want to be able to write a dll for my application that
According to the docs : If you want your application to use ComCtl32.dll version
There's a function, written in C++ and compiled as DLL, which I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.