vedang / pdf-tools

Emacs support library for PDF files.
https://pdftools.wiki
GNU General Public License v3.0
590 stars 83 forks source link

synctex_parser.c:8448:13: error: implicit declaration of function 'vasprintf' #286

Open Beakcraft opened 1 week ago

Beakcraft commented 1 week ago

Issues to Compile epdf server over/with emacs Trying to compile i get/got following error: synctex_parser.c: In function '_synctex_updater_print_gz': synctex_parser.c:8448:13: error: implicit declaration of function 'vasprintf'; did you mean 'vsprintf'? [-Wimplicit-function-declaration]   8448 |     if (vasprintf(&buffer, format, va) < 0) {     |       ^~~~~     |       vsprintf make[1]: [Makefile:484: libsynctex_a-synctex_parser.o] Error 1 make: [Makefile:346: all] Error 2

Steps to Reproduce the behaviour Steps to reproduce the behaviour:

  1. Put following code in your initiation file (.emacs.d/init.el for me, must delete .emacs or it wont load): (use-package pdf-tools :ensure t :config (pdf-tools-install)
  2. open any emacs file or run M(Alt)+x and type eval-buffer
  3. wait
  4. See error

What is the expected behaviour? no idea what i m doing, but Build succeeded (which i got now, will explain later) as an output seems legit. And opening pdfs with emacs should use the pdf-tools thingy (mode PDFView)

Desktop Please complete the following information:

Your pdf-tools install Please complete the following information:

Additional context I want to have an emacs pdf viewer autoupdating when saving my .tex (running auctex)- struggling hard with approx 0 coding experience

Solution? So i have honestly no idea what i m doing, neither on emacs nor on github (dont even know how to download smth off github to this day), but i located the file in my folders opend it up with emacs as my editor and tried editing the code there. editing vasprint to vsprint does not work, nor adding this: #define __STDC_WANT_LIB_EXT2__ 1

but I saw that the definition of vasprint was there and that it was conditional, since the compiler was lost, the if function must have returned negative but nevertheless run over the now undefined vasprint. So i put the #endif just before the definition of "static int vasprintf..." build succeeded now. I do believe this is not a proper solution so somebody might wanna give this a look I posted this because this gave me massive struggles to continue with my thesis in auctex. It made me reinstall emacs(lastly with msys2 whatever that is), Livetex (does not work through msys2) several times over. that weird pdf-tools server just wouldnt build. So maybe this helps somebody. Instuction Open .emacs.d\elpa\pdf-tools-1.1.0\server\synctex_parser.c on Windows this will be accessable through the C:\Users*your Username*\AppData (AppDate is usually hidden, so you need to press View in your Menu bar -> Show -> and tick Hidden Items)\Roaming Open the file, go to line ~8448 and put the "#endif" in front of the "static int vaspfintf..." save file, run emacs, succees.

Old code:


if defined(_MSC_VER)

include

include

include

static int vasprintf(char *ret,            const char format,            va_list ap) {   int len;   len = _vsnprintf(NULL, 0, format, ap);   if (len < 0) return -1;   ret = malloc(len + 1);   if (!ret) return -1;   _vsnprintf(ret, len+1, format, ap);   (ret)[len] = '\0';   return len; }

endif

/*   gzvprintf is not available until OSX 10.10  / static int _synctex_updater_print_gz(synctex_updater_p updater, const char format, ...) {   int result = 0;   if (updater) {     char * buffer;     va_list va;     va_start(va, format);     if (vasprintf(&buffer, format, va) < 0) {       _synctex_error("Out of memory...");     } else if ((result = (int)strlen(buffer))) {       result = gzwrite(updater->file.as_gzFile, buffer, (unsigned)result);     }     va_end(va);     free(buffer);   }   return result; } expand_more

Beakcraft commented 1 week ago

well. now i am struggling having following init.el file give me my desired results (namely C-c C-c resulting in a displayed and updated pdf in pdf-tools) (use-package auctex :ensure t :defer t :hook (Latex-mode . (lambda () (push (list 'output-pdf "PDF Tools") Tex-view-program-selection))))

(use-package pdf-tools :ensure t :config (pdf-tools-install))

(setq TeX-view-program-selection '((output-pdf "PDF Tools"))) (setq TeX-source-correlate-start-server t)

(add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer)