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

  • Home
  • SEARCH
  • 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 3347814
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:28:00+00:00 2026-05-18T01:28:00+00:00

It seems that Adobe Alchemy isn’t running global constructors. Here’s some simple test code:

  • 0

It seems that Adobe Alchemy isn’t running global constructors. Here’s some simple test code:

#include <stdio.h>

class TestClass {
public:
    TestClass(const char message[]) {
        printf("hello %s \n", message);
    }
};

TestClass global("global");

int main(int argc, char **argv) {
    TestClass local("local");
    printf("in main\n");
    return 0;
}

When compiled with native gcc it outputs:

hello global
hello local
in main

When compiled with alchemy gcc it outputs:

hello local
in main

This problem breaks lots of code, notably UnitTest++ (which depends on globals getting initialized to make its auto test-list functionality work).

I’d really like to get to the bottom of this. Is it a bug or a feature that just didn’t get implemented in time for the release? Is it possible to workaround?

EDIT: A relevant post on the Adobe Forums is here.

  • 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-18T01:28:01+00:00Added an answer on May 18, 2026 at 1:28 am

    I’ve run into the same problem. As far as I could tell, this seems to be the case:

    Every single static and global variable of class type will silently fail to be initialized if even a single class attempts dynamic allocation at any point during its initialization. Presumably this is because the ByteBuffer being used for dynamic memory isn’t yet available. I wish Alchemy would be more clear with its error messages, because at the moment it’s like a strand of old-timey Christmas lights where one dead bulb would cause the entire strand to shut off.

    For a workaround, once you’ve discovered the offending object, you’ll need to somehow defer its initialization to runtime. The three techniques that come to mind are pointers, lazy evaluation functions, or references to buffers initialized with placement new.

    Pointers

    // `global` is now a pointer
    TestClass *global;
    
    // all global variable initialization is found here now
    void init_globals() {
      global = new TestClass("global");
    }
    
    int main(int argc, char **argv) {
      // this needs to be explicitly called at the start Alchemy
      init_globals();
    

    You’ll then need to refactor your code, changing every occurence of global to (*global).

    Function

    // `global` is now a function
    TestClass& global() {
      // static locals are initialized when their functions are first called
      static TestClass global_("global");
      return global_;
    }
    

    Now you need to replace every occurence of global with global(). Notably, this is the only one of these three techniques that doesn’t require an explicit init_globals call. I recommend this way unless the name changing to global() is troublesome for some reason… in which case:

    Placement new

    // a memory buffer is created large enough to hold a TestClass object
    unsigned char global_mem[sizeof(TestClass)];
    // `global` is now a reference.  
    TestClass& global = *(TestClass*)(void*)global_mem;
    
    void init_globals() {
      // this initializes a new TestClass object inside our memory buffer
      new (global_mem) TestClass("global");
    }
    
    int main(int argc, char **argv) {
      init_globals();
    

    The advantage of this approach is you don’t need to change any other code, as global is still just called global. Unfortunately, maintaining an init_globals function can be troublesome.


    Edit:
    As discovered in a later question, in addition to dynamic allocation, functions containing static locals also cannot be called during Alchemy’s initialization.

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

Sidebar

Related Questions

It seems that in some cases, if you end up with nested modalPopups wrapped
A quick glance at the present-day internet would seem to indicate that Adobe Flash
Seems that requirements on safety do not seem to like systems that use AI
It seems that a List object cannot be stored in a List variable in
It seems that it is impossible to capture the keyboard event normally used for
It seems that Silverlight/WPF are the long term future for user interface development with
It seems that most of the installers for Perl are centered around installing Perl
It seems that anyone can snoop on incoming/outgoing .NET web service SOAP messages just
It seems that C# 3 hit me without me even noticing, could you guys
It seems that when I use a tool (such as winmerge) to update my

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.