[MacPorts] #58379: LyX @2.3.2: AppleScriptProxy.cpp:39:2: error: use of undeclared identifier 'strcpy'

MacPorts noreply at macports.org
Wed Apr 24 04:57:31 UTC 2019


#58379: LyX @2.3.2: AppleScriptProxy.cpp:39:2: error: use of undeclared identifier
'strcpy'
--------------------+----------------------------
 Reporter:  kencu   |      Owner:  kurthindenburg
     Type:  defect  |     Status:  assigned
 Priority:  Normal  |  Milestone:
Component:  ports   |    Version:
 Keywords:          |       Port:  LyX
--------------------+----------------------------
 When building LyX on systems that are **not** configured to use `libc++`
 (the default for darwin < 13) the build of Lyx fails:
 {{{
 AppleScriptProxy.cpp:39:2: error: use of undeclared identifier 'strcpy'
         strcpy (cstr, rval.c_str());
         ^
 }}}

 The same build with the same compiler works if building LyX against the
 libc++ headers.

 The file that fails is a bit complicated:
 {{{
 $ cat ./src/support/AppleScriptProxy.cpp
 // -*- C++ -*-
 /**
  * \file AppleScriptProxy.cpp
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
  * \author Benjamin Piwowarski
  *
  * Full author contact details are available in file CREDITS.
  */
 #include <config.h>

 #include "AppleScript.h"

 #include "DispatchResult.h"
 #include "FuncRequest.h"
 #include "LyX.h"
 #include "LyXAction.h"

 #include "frontends/Application.h"

 #include "support/docstring.h"
 #include "support/debug.h"

 #include <stdlib.h>

 using namespace std;
 using namespace lyx;

 extern "C" LyXFunctionResult applescript_execute_command(const char *cmd,
 const char *arg) {
         LYXERR(Debug::ACTION, "Running command [" << cmd << "] with
 arguments [" << arg << "]");
         FuncRequest fr(lyxaction.lookupFunc(cmd), from_utf8(arg));
         fr.setOrigin(FuncRequest::LYXSERVER);
         DispatchResult dr;
         theApp()->dispatch(fr, dr);

         string const rval = to_utf8(dr.message());
         char *cstr = (char*) malloc((rval.size()+1)*sizeof(rval[0]));
         strcpy (cstr, rval.c_str());

         // Returns the result
         LyXFunctionResult result;
         result.code = dr.error() ? -1 : 0;
         result.message = cstr;

         return result;
 }
 }}}

 But something about that file seems make the build against macports-
 libstdc++ unhappy.

 I tried various modifications to the strcpy command, like:
 {{{
 ::strcpy

 and

 std::strcpy
 }}}

 but that didn't work. However, adding
 {{{
 #include <stdlib.h>
 +#include <string.h>
 }}}
 does fix the build on 10.6 through 10.8. This fix is only needed if not
 building against libc++.

 At this moment, I'm not really certain why this is happening. This is a
 trial-and-error observation/fix.

 I'll generate a PR to fix this.

-- 
Ticket URL: <https://trac.macports.org/ticket/58379>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list