D
D
Denis Koveshnikov2016-07-17 21:13:43
C++ / C#
Denis Koveshnikov, 2016-07-17 21:13:43

Can Visual C++ limit the number of global variables?

Here is the actual code that the studio complains about with this error: error C2078: too many initializers.

#pragma once
#include "HTTPClient.h"

using namespace HTTP;
  static char *General[GENERAL_COUNT_HEADERS] = 
  {
      "CacheControl",
      "Connection",
      "Date",
      "MIMEVersion",
      "Pragma",
      "Trailer",
      "TransferEncoding",
      "Upgrade",
      "Via",
      "Warning"
  };

  static char *Request[REQUEST_COUNT_HEADERS] =
  {
    "Accept",
    "AcceptCharset",
    "AcceptEncoding",
    "AcceptLanguage",
    "Authorization",
    "ContentDispositionRq",
    "Expect",
    "From",
    "Host",
    "IfMatch",
    "IfModifiedSince",
    "IfNoneMatch",
    "IfRange",
    "IfUnmodifiedSince",
    "MaxForwards",
    "ProxyAuthorization",
    "Range",
    "Refer",
    "TE",
    "UserAgent"
  };
  static char *Response[RESPONSE_COUNT_HEADERS] =
  {
    "AcceptRanges",
    "Age",
    "Alternates",
    "ContentDispositionRs",
    "ETag",
    "Location",
    "ProxyAuthenticate",
    "Public",
    "RetryAfter",
    "Server",
    "Vary",
    "WWWAuthenticate"
  };
  static char Entity[ENTITY_COUNT_HEADERS] = 
  {
    "ContentDispositionE",
    "ContentEncoding",
    "ContentLanguage",
    "ContentLength",
    "ContentLocation",
    "ContentMD5",
    "ContentRange",
    "ContentType",
    "ContentVersion",
    "DerivedFrom",
    "Expires",
    "LastModified",
    "Link",
    "Title"
  };
HTTPClient::HTTPClient(int a)
{
  a=a;
};

int HTTPClient::Header(GeneralHeaders header, char *value)
{
  cout << General[header] << ": " << value << endl;
  return 0;
};
int HTTPClient::Header(RequestHeaders header, char *value)
{
  cout << Request[header] << ": " << value << endl;
  return 0;
};
/*int HTTPClient::Request(HTTPClient::Headers header)
{
  return 0;
}*/;

HTTPClient::~HTTPClient(void)
{
};

Thus the cursor becomes in the block of lines Entity. If you comment it out, then everything is OK, well, this is very strange, why would I be forbidden to use as many variables as I need? Does anyone have an opinion on this matter, maybe somehow it is possible to redefine this stupidity in the directives?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mamkaololosha, 2016-07-17
@odysset

You can either write to Microsoft to treat char as a string, or just write char* as done in arrays above.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question