Compiling fails, D programming (GDC) - console

So I have installed gdc trying to do a simple compile at command prompt. Not sure if my imports\includes actually work? What should I do? I am 100% sure the program compiles with Eclipse\dub\dtt\ldc...
*C:\Development\gdc\bin>x86_64-unknown-linux-gnu-gdc C:\Users\plann\Downloads\test\MessageApp\src\app.d --sysroot=C:\Development\gdc\sysroot -B "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib"
C:\Users\plann\Downloads\test\MessageApp\src\app.d:13:7: error: undefined identifier 'DWORD'
DWORD bakgrunfar = 0;
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:14:7: error: undefined identifier 'DWORD'
DWORD textfar = 0;
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:17:7: error: undefined identifier 'HFONT'
HFONT hFont, hOldFont;
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:17:14: error: undefined identifier 'HFONT'
HFONT hFont, hOldFont;
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:20:5: error: undefined identifier 'HWND'
int WindowProcedure (HWND, UINT, WPARAM, LPARAM );
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:20:5: error: undefined identifier 'UINT'
int WindowProcedure (HWND, UINT, WPARAM, LPARAM );
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:20:5: error: undefined identifier 'WPARAM'
int WindowProcedure (HWND, UINT, WPARAM, LPARAM );
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:20:5: error: undefined identifier 'LPARAM'
int WindowProcedure (HWND, UINT, WPARAM, LPARAM );
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:23:5: error: undefined identifier 'HINSTANCE'
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:23:5: error: undefined identifier 'HINSTANCE'
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:23:5: error: undefined identifier 'LPSTR'
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:44:5: error: undefined identifier 'HINSTANCE'
int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:44:5: error: undefined identifier 'HINSTANCE'
int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:44:5: error: undefined identifier 'LPSTR'
int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:99:5: error: undefined identifier 'HWND'
int WindowProcedure(HWND hwnd, UINT AEX, WPARAM wParam, LPARAM lParam) nothrow
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:99:5: error: undefined identifier 'UINT'
int WindowProcedure(HWND hwnd, UINT AEX, WPARAM wParam, LPARAM lParam) nothrow
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:99:5: error: undefined identifier 'WPARAM'
int WindowProcedure(HWND hwnd, UINT AEX, WPARAM wParam, LPARAM lParam) nothrow
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:99:5: error: undefined identifier 'LPARAM'
int WindowProcedure(HWND hwnd, UINT AEX, WPARAM wParam, LPARAM lParam) nothrow*

We cannot help without taking a look at the app.d. From the errors it seems that you did not import windows module that defines the various Windows-specific types.. Start with the following two typical imports:
import core.runtime;
import core.sys.windows.windows;
I strongly suggest you reading the following guide: https://wiki.dlang.org/D_for_Win32

Related

Casting a const void* pointer parameter into a const char* pointer, in memchr function

I have to reproduce the functioning of the memchr function, which returns the pointer of the first int c occurence.
Of course, size_t n argument has been measured by func strlen before being sent to ft_memchr func parameter.
But I keep on getting this compiling error (compiled with a main.c) "
ft_memchr.c:10:21: error: operand of type 'const void' where arithmetic or pointer type is required
if ((const char *)s[i] == (const char)c)
"
I'm clearly missing something... It seems I can't cast the const void* parameter into a const char* or even a char*, why is that ?
Thank you.
#include <string.h>
void *ft_memchr(const void *s, int c, size_t n)
{
size_t i;
i = 0;
while (i < n)
{
if ((const char *)s[i] == (const char)c)
return ((char *)s + i);
}
return (NULL);
}

QtXml/qdom.h proplems in a qt project

I'm using CGAL , libQGLViewer libraries in a project on QT creator , Fedora 27
but it shows errors on the header file of the libraries
Compile output:
/usr/include/QtXml/qdom.h:99:20: error: variable ‘Q_XML_EXPORT QDomImplementation’ has initializer but incomplete type
class Q_XML_EXPORT QDomImplementation
^~~~~~~~~~~~~~~~~~
/usr/include/QtXml/qdom.h:101:1: error: expected primary-expression before ‘public’
public:
^~~~~~
/usr/include/QtXml/qdom.h:101:1: error: expected ‘}’ before ‘public’
/usr/include/QtXml/qdom.h:101:1: error: expected ‘,’ or ‘;’ before ‘public’
/usr/include/QtXml/qdom.h:103:30: error: ‘QDomImplementation’ does not name a type
QDomImplementation(const QDomImplementation&);
^~~~~~~~~~~~~~~~~~
/usr/include/QtXml/qdom.h:103:50: error: expected constructor, destructor, or type conversion before ‘;’ token
QDomImplementation(const QDomImplementation&);
^
/usr/include/QtXml/qdom.h:104:26: error: expected constructor, destructor, or type conversion before ‘;’ token
~QDomImplementation();
^
/usr/include/QtXml/qdom.h:105:5: error: ‘QDomImplementation’ does not name a type
QDomImplementation& operator= (const QDomImplementation&);
^~~~~~~~~~~~~~~~~~
/usr/include/QtXml/qdom.h:106:28: error: ‘QDomImplementation’ does not name a type
bool operator== (const QDomImplementation&) const;
^~~~~~~~~~~~~~~~~~
/usr/include/QtXml/qdom.h:106:49: error: non-member function ‘bool operator==(const int&)’ cannot have cv-qualifier
bool operator== (const QDomImplementation&) const;
^~~~~
/usr/include/QtXml/qdom.h:106:49: error: ‘bool operator==(const int&)’ must have an argument of class or enumerated type
/usr/include/QtXml/qdom.h:107:28: error: ‘QDomImplementation’ does not name a type
bool operator!= (const QDomImplementation&) const;
^~~~~~~~~~~~~~~~~~
/usr/include/QtXml/qdom.h:107:49: error: non-member function ‘bool operator!=(const int&)’ cannot have cv-qualifier
bool operator!= (const QDomImplementation&) const;
^~~~~
/usr/include/QtXml/qdom.h:107:49: error: ‘bool operator!=(const int&)’ must have an argument of class or enumerated type
/usr/include/QtXml/qdom.h:110:69: error: non-member function ‘bool hasFeature(const QString&, const QString&)’ cannot have cv-qualifier
bool hasFeature(const QString& feature, const QString& version) const;
^~~~~
/usr/include/QtXml/qdom.h:121:1: error: expected unqualified-id before ‘private’
private:
^~~~~~~
/usr/include/QtXml/qdom.h:123:51: error: expected constructor, destructor, or type conversion before ‘;’ token
QDomImplementation(QDomImplementationPrivate*);
^
/usr/include/QtXml/qdom.h:125:5: error: ‘friend’ used outside of class
friend class QDomDocument;
^~~~~~
/usr/include/QtXml/qdom.h:126:1: error: expected declaration before ‘}’ token
};
all errors appear in QtXml/qdom.h file , I have no idea how to solve them
I appreciate any help,
thanks

Is it possible to have a const reference to a nonconst char pointer?

Is it possible to have a const reference to *argv and iterate through the array of pointers argv?
For the code below, I get the following warning:
a reference of type "const char *& (not const-qualified) cannot be initialized with a value of type "char *"
After building, I get this error message:
cannot convert from 'char *' to 'const char *&'.
#import <iostream>
using std::cout;
using std::endl;
int main (int argc, char * argv []) {
for (const char *& c = *argv; *c != '\0'; ++c) {
cout << *c << endl;
}
return 0;
}
I am confused because I know it is possible to have a const reference to a non-const variable like so:
int i = 42;
int &r1 = i;

php7.1RC5 enable dmalloc compiling error

I just wanted to build PHP7 with enable-dmalloc
enveronment:
the version of PHP is 7.1.0RC5
debian 8
gcc6.2
dmalloc 5.5.2
used this command:
./configure --prefix=/usr/local/php/70 --with-config-file-path=/usr/local/lib/php/70/etc --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --with-apxs2=/usr/local/httpd/2.4/bin/apxs --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pgsql=/usr/local/PostgreSQL/9.5 --with-pdo-mysql=/usr/local/mysql --with-pdo-pgsql=/usr/local/PostgreSQL/ --enable-ftp --enable-zip --with-bz2 --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir -with-zlib --enable-bcmath --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --with-freetype-dir --enable-gd-native-ttf --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-exif --enable-debug --enable-phpdbg --enable-phpdbg-webhelper --enable-phpdbg-debug --enable-dtrace --enable-dmalloc --with-openssl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-pear --enable-maintainer-zts
make
but it failed with the the Error Message:
/usr/include/malloc.h:38:35: error: expected declaration specifiers or ‘...’ before string constant extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
/usr/include/malloc.h:38:35: error: expected declaration specifiers or ‘...’ before numeric constant extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
In file included from /usr/local/src/php-7.1.0RC5/main/php.h:26:0,
from /usr/local/src/php-7.1.0RC5/ext/gd/libgd/gdhelpers.h:5,
from /usr/local/src/php-7.1.0RC5/ext/gd/libgd/gdft.c:13:
/usr/include/malloc.h:38:14: error: expected declaration specifiers or ‘...’ before ‘(’ token extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
/usr/include/malloc.h:38:14: error: expected declaration specifiers or ‘...’ before numeric constant extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
/usr/include/malloc.h:38:14: error: expected declaration specifiers or ‘...’ before numeric constant extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
/usr/include/malloc.h:38:14: error: expected declaration specifiers or ‘...’ before numeric constant extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
/usr/include/malloc.h:41:51: error: expected declaration specifiers or ‘...’ before string constant extern void *calloc (size_t __nmemb, size_t __size)
/usr/include/malloc.h:49:49: error: expected declaration specifiers or ‘...’ before string constant extern void *realloc (void *__ptr, size_t __size)
/usr/include/malloc.h:53:30: error: expected declaration specifiers or ‘...’ before string constant extern void free (void *__ptr) __THROW;
/usr/include/malloc.h:59:57: error: expected declaration specifiers or ‘...’ before string constant extern void *memalign (size_t __alignment, size_t __size)
/usr/include/malloc.h:63:35: error: expected declaration specifiers or ‘...’ before string constant extern void *valloc (size_t __size) __THROW __attribute_malloc__ __wur;
Makefile:1028: recipe for target 'ext/gd/libgd/gdft.lo' failed
make: *** [ext/gd/libgd/gdft.lo] Error 1
I see the source code in gdft.c, gdhelper.h and php.h, found this line:
#ifdef HAVE_DMALLOC
#include <dmalloc.h>
#endif
it maybe dmalloc caused this error, but I don't know why the error msg show malloc.h, I checked /usr/include, it has malloc.h and dmalloc.h two files
I install the package libdmalloc and libdmalloc-dev and I try to reinstall dmalloc with sourcecode but it's not helpful
What are the causes of these and how do I deal it ?

invalid types 'uint8_t {aka unsigned char}[int]' for array subscript

I copied a script from a YouTube video because there was no download link to the script, but now i'm always getting the same error message and I don't know what to do. Could you help me?
This is my code:
#include <VirtualWire.h>
int ledPassive = 5;
int ledActive = 7;
int motor = 8;
void setup() {
// put your setup code here, to run once:
pinMode(ledPassive,OUTPUT);
pinMode(ledActive,OUTPUT);
pinMode(motor,OUTPUT);
vw_set_ptt_inverted(true);
vw_set_rx_pin(12);
vw_setup(4000);
vw_rx_start();
}
void loop()
{
digitalWrite(ledPassive,HIGH);
digitalWrite(motor,LOW);
digitalWrite(ledActive,LOW);
uint8_t buf(VW_MAX_MESSAGE_LEN);
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) {
if (buf[0]=='X'){
digitalWrite(ledPassive,LOW);
for (int i=0;i<10;i++){
digitalWrite(motor,LOW);
digitalWrite(ledActive,HIGH);
delay(200);
digitalWrite(motor,HIGH);
digitalWrite(ledActive,LOW);
delay(200);
}
}
else if (buf[0]!='x'){
digitalWrite(ledPassive,HIGH);
}
}
}
And this is the error message:
Arduino: 1.6.10 (Windows 10), Board:"Arduino Nano, ATmega328"
In function 'void loop()':
sketch_aug18e_self_made:29: error: invalid types 'uint8_t {aka unsigned char}[int]' for array subscript
if (buf[0]=='X'){
^
sketch_aug18e_self_made:40: error: invalid types 'uint8_t {aka unsigned char}[int]' for array subscript
else if (buf[0]!='x'){
^
exit status 1
invalid types 'uint8_t {aka unsigned char}[int]' for array subscript
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Sorry for the bad language i'm dutch and not so very good at English
Try replacing
uint8_t buf(VW_MAX_MESSAGE_LEN);
with
uint8_t buf[VW_MAX_MESSAGE_LEN];
You're using improper syntax for declaring an array.

Resources