genepi icon indicating copy to clipboard operation
genepi copied to clipboard

First char is zeroed when passing string as char *

Open mcpiroman opened this issue 5 years ago • 0 comments

#include <genepi/genepi.h>

void test1(char* str1) {
    for(int i = 0; i < 5; i++) {
        std::cout << (int)str1[i] << " ";
    }
}

GENEPI_MODULE( lib );
GENEPI_FUNCTION( test1 );
const lib = require('./build/Release/lib.node')
lib.test1('test')

Prints: 0 101 115 116 0 (which is \0est\0 in ascii)

Platform:

Microsoft Windows NT 10.0.18363.0
Visual Studio 16 2019 generator
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
-- The C compiler identification is MSVC 19.28.29335.0
-- The CXX compiler identification is MSVC 19.28.29335.0

mcpiroman avatar Dec 19 '20 16:12 mcpiroman