1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Rep Power

    Question Arduino library to Visual c++ dll

    Hey all I am trying my best to fixed these few errors below. The C++ code is from an Arduino library that i wanted to convert to Visual C++ dll for use in one of my C# applications.

    These are the areas that have the errors:

    void AES::do_aes_encrypt(BYTE *plain,int size_p,BYTE *cipher,BYTE *key, int bits, BYTE ivl [N_BLOCK]){
      BYTE plain_p[get_size()];
      int blocks = get_size() / N_BLOCK;
      set_key(key, bits) ;
      cbc_encrypt(plain_p, cipher, blocks, ivl);
    The "BYTE plain_p[get_size()];" has the error of "'this' cannot be used in a constant expression".

    string AES::letsDecrypt(BYTE *key, string msg, AES aes) {
      char data_decoded[200];
      char iv_decoded[200];
      char temp[200];
      BYTE out[200];
      aes.set_key(key, sizeof(key));
      msg.toCharArray(temp, 200);
      int b64len = base64_decode(data_decoded, temp, msg.length());
      string(iv_Encoded).toCharArray(temp, 200);
      base64_decode(iv_decoded, temp, string(iv_Encoded).length());  
      aes.do_aes_decrypt((BYTE *)data_decoded, b64len, out, key, 128, (BYTE *)iv_decoded);
      char message[msg.length()];
      char* msgBase64 = (char *)out;
      base64_decode(message, (char *)out, msg.length());
      return std::string(message);
    The "msg.toCharArray(temp, 200);" has the error of "class "std::basic_string<char, std::char_traits<char>, std::allocator<char>>" has no member "toCharArray"".

    Another error on the same code above "char message[msg.length()];" has the error of "expression must have a constant value".

    And lastly i get this error: "unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?" Which when i try to include it-it says it cant be found.

    Help would be great!
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2017
    Rep Power
    How's your research for conversion so far?

IMN logo majestic logo threadwatch logo seochat tools logo