thiagoelg / node-printer

Native node.js printer
125 stars 75 forks source link

Failed to compile with nw-gyp #58

Open TheRulisp opened 1 year ago

TheRulisp commented 1 year ago

My setup

When I try to compile package for nw.js with this command

nw-gyp rebuild --target=0.68.0 --msvs_version=2019 --arch=ia32

I receive a lot of errors from compiler like this one: pasting formed '->pPrinterName', an invalid preprocessing token

As a part of my attempt to resolve this problem, I found out that this is caused by these macroses in node_printer_win.cc (lines 214 and 346)

define ADD_V8_STRING_PROPERTY(name, key) if((job->##key != NULL) && (*job->##key != L'\0')) \

    {                                   \
        Nan::Set(result_printer_job, V8_STRING_NEW_UTF8(#name), V8_STRING_NEW_2BYTES((uint16_t*)job->##key)); \
    }

define ADD_V8_STRING_PROPERTY(name, key) if((printer->##key != NULL) && (*printer->##key != L'\0')) \

    {                                   \
        Nan::Set(result_printer, V8_STRING_NEW_UTF8(#name), V8_STRING_NEW_2BYTES((uint16_t*)printer->##key)); \
    }

If I remove these token-pasting ##, package will compile with some warnings from compiler and, probably, will works well (I don't have any printer at hand right now, but at least my application starts and shows list of printers from the system).

In addition, I want to say that if I try to compile package with node-gyp it works ok, so, I'm not quite sure that this issue is related to this package exactly.

Ready to answer your questions and provide additional info if required