Code Monkey home page Code Monkey logo

Comments (5)

AndreRenaud avatar AndreRenaud commented on August 23, 2024

Hi. I use gcc/g++ for most of my builds, so it should already work. Can you tell me what warnings you're seeing?

from pdfgen.

nidoro avatar nidoro commented on August 23, 2024

Well, this is my test program:

#include "/home/davidoro/libs/PDFGen-master/pdfgen.h"
#include "/home/davidoro/libs/PDFGen-master/pdfgen.c"

int main(int argc, char* argv[]) {
    return 0;
}

And this is the output when I run g++ ./main.cpp -o test

In file included from ./main.cpp:3:
/home/davidoro/libs/PDFGen-master/pdfgen.c:101: warning: "_POSIX_SOURCE" redefined
 #define _POSIX_SOURCE     /* For localtime_r */
 
In file included from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
                 from /usr/include/stdint.h:26,
                 from /usr/lib/gcc/x86_64-linux-gnu/8/include/stdint.h:9,
                 from /home/davidoro/libs/PDFGen-master/pdfgen.h:16,
                 from ./main.cpp:2:
/usr/include/features.h:264: note: this is the location of the previous definition
 # define _POSIX_SOURCE 1
 
In file included from ./main.cpp:3:
/home/davidoro/libs/PDFGen-master/pdfgen.c:102: warning: "_XOPEN_SOURCE" redefined
 #define _XOPEN_SOURCE 600 /* for M_SQRT2 */
 
In file included from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
                 from /usr/include/stdint.h:26,
                 from /usr/lib/gcc/x86_64-linux-gnu/8/include/stdint.h:9,
                 from /home/davidoro/libs/PDFGen-master/pdfgen.h:16,
                 from ./main.cpp:2:
/usr/include/features.h:203: note: this is the location of the previous definition
 # define _XOPEN_SOURCE 700
 
In file included from ./main.cpp:3:
/home/davidoro/libs/PDFGen-master/pdfgen.c: In function ‘int flexarray_set(flexarray*, int, void*)’:
/home/davidoro/libs/PDFGen-master/pdfgen.c:298:22: error: invalid conversion from ‘void*’ to ‘void***’ [-fpermissive]
         flex->bins = bins;
                      ^~~~
/home/davidoro/libs/PDFGen-master/pdfgen.c:300:19: error: invalid conversion from ‘void*’ to ‘void**’ [-fpermissive]
             calloc(flexarray_get_bin_size(flex, flex->bin_count - 1),
             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    sizeof(void *));
                    ~~~~~~~~~~~~~~~
/home/davidoro/libs/PDFGen-master/pdfgen.c: In function ‘ssize_t dstr_ensure(dstr*, size_t)’:
/home/davidoro/libs/PDFGen-master/pdfgen.c:362:27: error: invalid conversion from ‘void*’ to ‘char*’ [-fpermissive]
         new_data = realloc(str->data, new_len);
                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~
/home/davidoro/libs/PDFGen-master/pdfgen.c: In function ‘pdf_object* pdf_get_object(const pdf_doc*, int)’:
/home/davidoro/libs/PDFGen-master/pdfgen.c:478:25: error: invalid conversion from ‘void*’ to ‘pdf_object*’ [-fpermissive]
     return flexarray_get(&pdf->objects, index);
            ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/home/davidoro/libs/PDFGen-master/pdfgen.c: In function ‘pdf_object* pdf_add_object(pdf_doc*, int)’:
/home/davidoro/libs/PDFGen-master/pdfgen.c:525:17: error: invalid conversion from ‘void*’ to ‘pdf_object*’ [-fpermissive]
     obj = calloc(1, sizeof(*obj));
           ~~~~~~^~~~~~~~~~~~~~~~~
/home/davidoro/libs/PDFGen-master/pdfgen.c: In function ‘pdf_doc* pdf_create(float, float, const pdf_info*)’:
/home/davidoro/libs/PDFGen-master/pdfgen.c:576:17: error: invalid conversion from ‘void*’ to ‘pdf_doc*’ [-fpermissive]
     pdf = calloc(1, sizeof(*pdf));
           ~~~~~~^~~~~~~~~~~~~~~~~
/home/davidoro/libs/PDFGen-master/pdfgen.c:591:23: error: invalid conversion from ‘void*’ to ‘pdf_info*’ [-fpermissive]
     obj->info = calloc(sizeof(*obj->info), 1);
                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/home/davidoro/libs/PDFGen-master/pdfgen.c: In function ‘int pdf_save_object(pdf_doc*, FILE*, int)’:
/home/davidoro/libs/PDFGen-master/pdfgen.c:805:30: error: invalid conversion from ‘void*’ to ‘pdf_object*’ [-fpermissive]
                 flexarray_get(&object->pag/e.children, i);
                 ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/davidoro/libs/PDFGen-master/pdfgen.c:834:30: error: invalid conversion from ‘void*’ to ‘pdf_object*’ [-fpermissive]
             f = flexarray_get(&object->bookmark.children, 0);
                 ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/davidoro/libs/PDFGen-master/pdfgen.c:835:30: error: invalid conversion from ‘void*’ to ‘pdf_object*’ [-fpermissive]
             l = flexarray_get(&object->bookmark.children, nchildren - 1);
                 ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/davidoro/libs/PDFGen-master/pdfgen.c: In function ‘pdf_object* pdf_add_raw_jpeg(pdf_doc*, const char*)’:
/home/davidoro/libs/PDFGen-master/pdfgen.c:2239:23: error: invalid conversion from ‘void*’ to ‘uint8_t*’ {aka ‘unsigned char*’} [-fpermissive]
     jpeg_data = malloc(len);
                 ~~~~~~^~~~~
/home/davidoro/libs/PDFGen-master/pdfgen.c: In function ‘int pdf_add_ppm(pdf_doc*, pdf_object*, float, float, float, float, const char*)’:
/home/davidoro/libs/PDFGen-master/pdfgen.c:2339:18: error: invalid conversion from ‘void*’ to ‘uint8_t*’ {aka ‘unsigned char*’} [-fpermissive]
     data = malloc(size);
            ~~~~~~^~~~~~

I'm using gcc version 8.3.0 on Ubuntu 19.04

from pdfgen.

AndreRenaud avatar AndreRenaud commented on August 23, 2024

This is caused by compiling the C code as C++. You probably want to use gcc to compile pdfgen.c into pdfgen.o, and then link it against your c++.
However it's not particularly difficult for me to fix up those things that g++ is warning against, so I've done that as well. Either option should work - can I get you to pull the latest code and retry it?

from pdfgen.

AndreRenaud avatar AndreRenaud commented on August 23, 2024

I'll leave this issue open until you've had a chance to double check things. Let me know how it works for you now.

from pdfgen.

nidoro avatar nidoro commented on August 23, 2024

Hey, just tried out the latest code and the warnings have been removed. Thanks for that! It will be a very usefull library to have.

Cheers!

from pdfgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.