ARM Technical Support Knowledge Articles

How do I dynamically update compile-time configured strings in MDK-Middleware?

Applies to: Embedded Software


When using the MDK-Professional middleware, I can configure strings by using header files and corresponding wizard at compile time. However, no Application Program Interfaces (APIs) are provided to change the strings at runtime. How do I update those strings dynamically? 

Suppose that you use the Web Server (HTTP Server) service of Network middleware. The Authentication Realm is a string defined in the Net_Config_HTTP_Server.h configuration header file as shown below:

//     <s.20>Authentication Realm

//     <i>Defines the protection space on server

//     <i>Default: "Embedded WEB Server"

#define HTTP_SERVER_AUTH_REALM      "Embedded WEB Server"

To search the macro HTTP_SERVER_AUTH_REALM in files, press Ctrl+Shift+F in uVision. You can find that the macro HTTP_SERVER_AUTH_REALM is used as the initial value of a constant configuration structure, as shown in the following code:

NET_HTTP_CFG net_http_config = {









To further understand the configuration structure, you can search the user-defined type NET_HTTP_CFG, and find the following definition:

/// HTTP Server Configuration info

typedef struct net_http_cfg {


  const char *Realm;                    ///< Authentication realm space


} const NET_HTTP_CFG;

The keyword const in the code above indicates that the configuration structure and its member Realm is supposed to be constant during runtime. That is why no dedicated APIs are provided to update the strings dynamically. For normal cases, you can stop here and send a feature enhancement request to


In some rare cases, you have to change those strings at runtime because of application requirements. However, the risks of potential malfunctions can be introduced, because this middleware usage is abnormal, not fully tested, and not guaranteed. If you know the consequence and risks and still choose to proceed, you can perform the following steps to change the strings dynamically:

   1. Create a string buffer in your project with a fixed size. For example:

      char g_cREALM[256] = {"Authentication String"};

   2. Update the macro content in the target configuration header file with the string buffer. For example:

    #define HTTP_SERVER_AUTH_REALM (const char *)g_strREALM  

   3. Add a declaration for the string buffer in the configuration header file. For example:

    extern char g_strREALM[256];  

After these steps, you can dynamically update the target string stored in the buffer. 

Related Information

Rate this article

Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential