Author Topic: error "You must include my_global.h in the code for the build to be correct  (Read 5535 times)

Offline Rahul

  • Multiple posting newcomer
  • *
  • Posts: 25

hi to all, I've centos 7 and codeblocks 17 in VM. I am trying to build a program in which i am accessing MySQL database from c++ 11 .
In this following program :-

product.h :-
------------
Code
#ifndef PRODUCT_H
#define PRODUCT_H

#include <mysql/my_global.h>
#include <mysql/my_sys.h>
#include <mysql/mysql.h>
#include "draw.h"
#include "stat.h"
class product
{
    public:
        product();
        virtual ~product();
        product(const product& other);
        product& operator=(const product& other);

        void showAllProduct();

        void printDashes(MYSQL_RES * resset);
        static void printError(MYSQL *conn, char * message);
};

#endif // PRODUCT_H


product.cpp:-

Code
#include "product.h"
#include <string>
#include "stat.h"

using std::string;
using std::cout;
using std::cin;
using std::endl;

class Conn;

product::product()
{
    //ctor
}

product::~product()
{
    //dtor
}

product::product(const product& other)
{
    //copy ctor
}

product& product::operator=(const product& rhs)
{
    if (this == &rhs) return *this; // handle self assignment
    //assignment operator
    return *this;
}

void product::printDashes(MYSQL_RES * resset)
{
    unsigned int i, j;

    mysql_field_seek(resset, 0);
    clrscr();
    cout << "+";

    for(i = 0; i < mysql_num_fields(resset); i++)
    {
        Conn::field = mysql_fetch_field(resset);
        for(j = 0; j < Conn::field->max_length + 2; j++ )
        {
            cout << "-";
        }
        cout << "+";
    }
    cout << endl;
}

void product::showAllProduct()
{

    MYSQL * conn = Conn::connection();

    cout << " inside show all produucts";
    cin.get();
     char choose;
     clrscr();
     drawrect();
    int l = 5;
    gotoxy(15, 5);

    cout << "Welcome To Electronic Store";
    cin.get();
    gotoxy(15, 6);
    cout << "Show All Items Menu";

    cin.get();

    string strQuery = "select *from tableProductRecords";

    cout << strQuery << endl;

    int qState = mysql_query(conn, strQuery.c_str());

    cout << " before mysql_query " <<endl;

    cout << " After qstate " <<endl;
        if(qState == 0 )
        {
            cout << "in side qState " << endl;
            Conn::res = mysql_store_result(conn);

            cout << "after resuslt set ";

            mysql_field_seek(Conn::res, 0);

            while((Conn::row = mysql_fetch_row(Conn::res))!= nullptr )
            {
                printDashes(Conn::res);
            }
        }
        else
        {
            cout << " error : " << "  "<< mysql_errno(conn) << "  " << endl;

        }
    cin.get();
}

stat.h is :-

Code
#ifndef STAT_H_INCLUDED
#define STAT_H_INCLUDED

#include <mysql/my_global.h>
#include <mysql/my_sys.h>
#include <mysql/mysql.h>
#include "draw.h"
#include "getchoice.h"
#include "product.h"
#include <iostream>

using std::cout;
using std::endl;

char * menu[] ={
    "1.  Show All Products",
    "2.  Add New Product.",
    "3.  Add New Members.",
    "4.  View An Existing Product Records.",
    "5.  View An Existing Member's Record.",
    "6.  Billing.",
    "7.  Today's Sail.",
    "8.  Modify Product Record.",
    "9.  Modify Member's Record.",
    "10. Instructions.",
    "11. Exit.",
    NULL
};

    static char *opt_host = "serverora11gr2.db.net";
    static char *opt_user_name = "rahul";
    static char *opt_password = "rahul";
    static unsigned int  opt_port = 3306;
    static char *opt_socket_name = NULL;
    static char *opt_db_nme = "cbs";
    static unsigned int opt_flags = 0;


class   Conn
{
public:
    static MYSQL *conn, mysql;
    static int qstate;
    static MYSQL_ROW row;
    static MYSQL_RES* res;
    static MYSQL_FIELD *field;

    static MYSQL* connection();
    static void printError(MYSQL *conn, char * message);

};




#endif // STAT_H_INCLUDED
stat.cpp:-
Code
#include "stat.h"

static void printError(MYSQL *conn, char * message)
{
    gotoxy(15, 18);
    cout << *message;

    if(conn != NULL)
    {
        gotoxy(15, 19);
        cout << "Error is : " << mysql_errno(conn) << "  " << mysql_sqlstate(conn) << "  "<< mysql_error(conn);
    }
}


MYSQL * Conn::connection()
{
    if(mysql_library_init(0,NULL, NULL))
    {
        cout << "mysql lib init " << endl;
        exit(1);
    }

    conn = mysql_init(NULL);
    if(conn == NULL)
    {
        cout<< "conn is NULL";
        //cin.get();
        exit(2);
    }

    conn = mysql_real_connect (&mysql,"serverora11gr2.db.net","rahul","rahul","cbs",3306,NULL,0);
    return conn;
}


here is mine header file :-
Code
#ifndef STAT_H_INCLUDED
#define STAT_H_INCLUDED

#include <mysql/my_global.h>
#include <mysql/my_sys.h>
#include <mysql/mysql.h>
#include "draw.h"
#include "getchoice.h"
#include "product.h"
#include <iostream>

using std::cout;
using std::endl;

char * menu[] ={
    "1.  Show All Products",
    "2.  Add New Product.",
    "3.  Add New Members.",
    "4.  View An Existing Product Records.",
    "5.  View An Existing Member's Record.",
    "6.  Billing.",
    "7.  Today's Sail.",
    "8.  Modify Product Record.",
    "9.  Modify Member's Record.",
    "10. Instructions.",
    "11. Exit.",
    NULL
};

    static char *opt_host = "serverora11gr2.db.net";
    static char *opt_user_name = "rahul";
    static char *opt_password = "rahul";
    static unsigned int  opt_port = 3306;
    static char *opt_socket_name = NULL;
    static char *opt_db_nme = "cbs";
    static unsigned int opt_flags = 0;

class Conn
{
public:
    static MYSQL *conn;
    static MYSQL mysql;
    static int qstate;
    static MYSQL_ROW row;
    static MYSQL_RES* res;
    static MYSQL_FIELD *field;

    static MYSQL* connection();
    static void printError(MYSQL *conn, char * message);

};
#endif // STAT_H_INCLUDED
and Con::field is defind here ( in stat.cpp ):-

Code
#include <mysql/my_global.h>

#include "stat.h"

    Conn::conn = Conn::connection();
    Conn::mysql = NULL;
    Conn::qstate = 0;
    Conn::row = 0;
    Conn::res = nullptr;
    Conn::field = nullptr;

MYSQL * Conn::connection()
{
    //MY_INIT(argv[0]);

     //
     mysql_init(&mysql);

    if(mysql_library_init(0,NULL, NULL))
    {
        cout << "mysql lib init " << endl;
        exit(1);
    }

    conn = mysql_init(NULL);
    if(conn == NULL)
    {
        cout<< "conn is NULL";
        //cin.get();
        exit(2);
    }

    conn = mysql_real_connect (&mysql,"serverora11gr2.db.net","rahul","rahul","cbs",3306,NULL,0);
    return conn;
}


void Conn::printError(MYSQL *conn, char * message)
{
    gotoxy(15, 18);
    cout << *message;

    if(conn != NULL)
    {
        gotoxy(15, 19);
        cout << "Error is : " << mysql_errno(conn) << "  " << mysql_sqlstate(conn) << "  "<< mysql_error(conn);
    }
}
problem is that it showing following errors :-  even after including "mysql/my_global.h"
Code
||=== Build: Release in cbs (compiler: GNU GCC Compiler) ===|
/usr/include/mysql/mysql/psi/psi.h|40|error: #error "You must include my_global.h in the code for the build to be correct."|
/usr/include/mysql/mysql/psi/psi.h|40|error: #error "You must include my_global.h in the code for the build to be correct."|
/usr/include/c++/4.8.2/bits/stl_algobase.h|239|error: macro "min" passed 3 arguments, but takes just 2|
/usr/include/c++/4.8.2/bits/stl_algobase.h|260|error: macro "max" passed 3 arguments, but takes just 2|
/usr/include/mysql/mysql/psi/mysql_thread.h||In function ‘int inline_mysql_cond_wait(mysql_cond_t*, mysql_mutex_t*, const char*, uint)’:|
/usr/include/mysql/mysql/psi/mysql_thread.h|1151|error: ‘my_cond_wait’ was not declared in this scope|
/usr/include/mysql/mysql/psi/mysql_thread.h|1162|error: ‘my_cond_wait’ was not declared in this scope|
/usr/include/mysql/mysql/psi/mysql_thread.h||In function ‘int inline_mysql_cond_timedwait(mysql_cond_t*, mysql_mutex_t*, const timespec*, const char*, uint)’:|
/usr/include/mysql/mysql/psi/mysql_thread.h|1188|error: ‘my_cond_timedwait’ was not declared in this scope|
/usr/include/mysql/mysql/psi/mysql_thread.h|1199|error: ‘my_cond_timedwait’ was not declared in this scope|
/usr/include/c++/4.8.2/bits/stl_algobase.h|193|error: expected unqualified-id before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|193|error: expected ‘)’ before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|193|error: expected ‘)’ before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|193|error: expected initializer before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|216|error: expected unqualified-id before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|216|error: expected ‘)’ before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|216|error: expected ‘)’ before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|216|error: expected initializer before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|239|error: ‘std::min’ declared as an ‘inline’ variable|
/usr/include/c++/4.8.2/bits/stl_algobase.h|239|error: template declaration of ‘const _Tp& std::min’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|242|error: expected primary-expression before ‘if’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|242|error: expected ‘}’ before ‘if’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|244|error: expected unqualified-id before ‘return’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|260|error: ‘max’ declared as an ‘inline’ variable|
/usr/include/c++/4.8.2/bits/stl_algobase.h|260|error: template declaration of ‘const _Tp& max’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|263|error: expected primary-expression before ‘if’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|263|error: expected ‘}’ before ‘if’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|265|error: expected unqualified-id before ‘return’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|266|error: expected declaration before ‘}’ token|
/usr/include/mysql/mysql/psi/psi.h|40|error: #error "You must include my_global.h in the code for the build to be correct."|
/usr/include/c++/4.8.2/bits/stl_algobase.h|239|error: macro "min" passed 3 arguments, but takes just 2|
/usr/include/c++/4.8.2/bits/stl_algobase.h|260|error: macro "max" passed 3 arguments, but takes just 2|
/usr/include/mysql/mysql/psi/mysql_thread.h||In function ‘int inline_mysql_cond_wait(mysql_cond_t*, mysql_mutex_t*, const char*, uint)’:|
/usr/include/mysql/mysql/psi/mysql_thread.h|1151|error: ‘my_cond_wait’ was not declared in this scope|
/usr/include/mysql/mysql/psi/mysql_thread.h|1162|error: ‘my_cond_wait’ was not declared in this scope|
/usr/include/mysql/mysql/psi/mysql_thread.h||In function ‘int inline_mysql_cond_timedwait(mysql_cond_t*, mysql_mutex_t*, const timespec*, const char*, uint)’:|
/usr/include/mysql/mysql/psi/mysql_thread.h|1188|error: ‘my_cond_timedwait’ was not declared in this scope|
/usr/include/mysql/mysql/psi/mysql_thread.h|1199|error: ‘my_cond_timedwait’ was not declared in this scope|
/usr/include/c++/4.8.2/bits/stl_algobase.h|193|error: expected unqualified-id before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|193|error: expected ‘)’ before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|193|error: expected ‘)’ before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|193|error: expected initializer before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|216|error: expected unqualified-id before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|216|error: expected ‘)’ before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|216|error: expected ‘)’ before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|216|error: expected initializer before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|239|error: ‘std::min’ declared as an ‘inline’ variable|
/usr/include/c++/4.8.2/bits/stl_algobase.h|239|error: template declaration of ‘const _Tp& std::min’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|242|error: expected primary-expression before ‘if’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|242|error: expected ‘}’ before ‘if’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|244|error: expected unqualified-id before ‘return’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|260|error: ‘max’ declared as an ‘inline’ variable|
/usr/include/c++/4.8.2/bits/stl_algobase.h|260|error: template declaration of ‘const _Tp& max’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|263|error: expected primary-expression before ‘if’|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|


I already included "mysql/my_global.h" but even this problem arised.


Offline Rahul

  • Multiple posting newcomer
  • *
  • Posts: 25
Code
-------------- Build: Release in cbs (compiler: GNU GCC Compiler)---------------

g++ -Wall -fexceptions -O2 -std=c++11 -m64 -I/usr/include/mysql -c /opt/projects/c++/cbs/cbs/main.cpp -o obj/Release/main.o
g++ -Wall -fexceptions -O2 -std=c++11 -m64 -I/usr/include/mysql -c /opt/projects/c++/cbs/cbs/product.cpp -o obj/Release/product.o
g++ -Wall -fexceptions -O2 -std=c++11 -m64 -I/usr/include/mysql -c /opt/projects/c++/cbs/cbs/stat.cpp -o obj/Release/stat.o
g++ -L/usr/lib64/mysql -o bin/Release/cbs obj/Release/draw.o obj/Release/getchoice.o obj/Release/main.o obj/Release/product.o obj/Release/stat.o  -s -m64  -lmysqlclient -lpthread
In file included from /usr/include/c++/4.8.2/algorithm:61:0,
                 from /opt/projects/c++/cbs/cbs/main.cpp:2:
/usr/include/c++/4.8.2/bits/stl_algobase.h:239:56: error: macro "min" passed 3 arguments, but takes just 2
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
In file included from /usr/include/mysql/mysql/psi/mysql_thread.h:57:0,
                 from /usr/include/mysql/my_pthread.h:750,
                 from /usr/include/mysql/my_sys.h:34,
                 from /opt/projects/c++/cbs/cbs/product.h:5,
                 from /opt/projects/c++/cbs/cbs/product.cpp:2:
/usr/include/mysql/mysql/psi/psi.h:40:2: error: #error "You must include my_global.h in the code for the build to be correct."
 #error "You must include my_global.h in the code for the build to be correct."
  ^
In file included from /usr/include/c++/4.8.2/bits/char_traits.h:39:0,
                 from /usr/include/c++/4.8.2/ios:40,
                 from /usr/include/c++/4.8.2/ostream:38,
                 from /usr/include/c++/4.8.2/iostream:39,
                 from /opt/projects/c++/cbs/cbs/draw.h:4,
                 from /opt/projects/c++/cbs/cbs/product.h:7,
                 from /opt/projects/c++/cbs/cbs/product.cpp:2:
/usr/include/c++/4.8.2/bits/stl_algobase.h:239:56: error: macro "min" passed 3 arguments, but takes just 2
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
                                                        ^
/usr/include/c++/4.8.2/bits/stl_algobase.h:260:56: error: macro "max" passed 3 arguments, but takes just 2
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
                                                        ^
In file included from /usr/include/mysql/my_pthread.h:750:0,
                 from /usr/include/mysql/my_sys.h:34,
                 from /opt/projects/c++/cbs/cbs/product.h:5,
                 from /opt/projects/c++/cbs/cbs/product.cpp:2:
/usr/include/mysql/mysql/psi/mysql_thread.h: In function ‘int inline_mysql_cond_wait(mysql_cond_t*, mysql_mutex_t*, const char*, uint)’:
/usr/include/mysql/mysql/psi/mysql_thread.h:1151:56: error: ‘my_cond_wait’ was not declared in this scope
     result= my_cond_wait(&that->m_cond, &mutex->m_mutex);
                                                        ^
/usr/include/mysql/mysql/psi/mysql_thread.h:1162:54: error: ‘my_cond_wait’ was not declared in this scope
   result= my_cond_wait(&that->m_cond, &mutex->m_mutex);
                                                      ^
/usr/include/mysql/mysql/psi/mysql_thread.h: In function ‘int inline_mysql_cond_timedwait(mysql_cond_t*, mysql_mutex_t*, const timespec*, const char*, uint)’:
/usr/include/mysql/mysql/psi/mysql_thread.h:1188:70: error: ‘my_cond_timedwait’ was not declared in this scope
     result= my_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime);
                                                                      ^
/usr/include/mysql/mysql/psi/mysql_thread.h:1199:68: error: ‘my_cond_timedwait’ was not declared in this scope
   result= my_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime);
                                                                    ^
In file included from /opt/projects/c++/cbs/cbs/product.cpp:1:0:
/usr/include/c++/4.8.2/bits/stl_algobase.h: At global scope:
/usr/include/c++/4.8.2/bits/stl_algobase.h:193:5: error: expected unqualified-id before ‘const’
     min(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/4.8.2/bits/stl_algobase.h:193:5: error: expected ‘)’ before ‘const’
/usr/include/c++/4.8.2/bits/stl_algobase.h:193:5: error: expected ‘)’ before ‘const’
/usr/include/c++/4.8.2/bits/stl_algobase.h:193:5: error: expected initializer before ‘const’
/usr/include/c++/4.8.2/bits/stl_algobase.h:216:5: error: expected unqualified-id before ‘const’
     max(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/4.8.2/bits/stl_algobase.h:216:5: error: expected ‘)’ before ‘const’
/usr/include/c++/4.8.2/bits/stl_algobase.h:216:5: error: expected ‘)’ before ‘const’
/usr/include/c++/4.8.2/bits/stl_algobase.h:216:5: error: expected initializer before ‘const’
In file included from /usr/include/c++/4.8.2/bits/char_traits.h:39:0,
                 from /usr/include/c++/4.8.2/ios:40,
                 from /usr/include/c++/4.8.2/ostream:38,
                 from /usr/include/c++/4.8.2/iostream:39,
                 from /opt/projects/c++/cbs/cbs/draw.h:4,
                 from /opt/projects/c++/cbs/cbs/product.h:7,
                 from /opt/projects/c++/cbs/cbs/product.cpp:2:
/usr/include/c++/4.8.2/bits/stl_algobase.h:239:5: error: ‘std::min’ declared as an ‘inline’ variable
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^
/usr/include/c++/4.8.2/bits/stl_algobase.h:239:5: error: template declaration of ‘const _Tp& std::min’
/usr/include/c++/4.8.2/bits/stl_algobase.h:242:7: error: expected primary-expression before ‘if’
       if (__comp(__b, __a))
       ^
/usr/include/c++/4.8.2/bits/stl_algobase.h:242:7: error: expected ‘}’ before ‘if’
/usr/include/c++/4.8.2/bits/stl_algobase.h:244:7: error: expected unqualified-id before ‘return’
       return __a;
       ^
/usr/include/c++/4.8.2/bits/stl_algobase.h:260:5: error: ‘max’ declared as an ‘inline’ variable
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^
/usr/include/c++/4.8.2/bits/stl_algobase.h:260:5: error: template declaration of ‘const _Tp& max’
/usr/include/c++/4.8.2/bits/stl_algobase.h:263:7: error: expected primary-expression before ‘if’
       if (__comp(__a, __b))
       ^
/usr/include/c++/4.8.2/bits/stl_algobase.h:263:7: error: expected ‘}’ before ‘if’
/usr/include/c++/4.8.2/bits/stl_algobase.h:265:7: error: expected unqualified-id before ‘return’
       return __a;
       ^
/usr/include/c++/4.8.2/bits/stl_algobase.h:266:5: error: expected declaration before ‘}’ token
     }
     ^
Process terminated with status 1 (0 minute(s), 0 second(s))
 
                                                        ^
/usr/include/c++/4.8.2/bits/stl_algobase.h:260:56: error: macro "max" passed 3 arguments, but takes just 2
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
                                                        ^
In file included from /usr/include/c++/4.8.2/bits/stl_algo.h:60:0,
                 from /usr/include/c++/4.8.2/algorithm:62,
                 from /opt/projects/c++/cbs/cbs/main.cpp:2:
/usr/include/c++/4.8.2/bits/algorithmfwd.h:360:41: error: macro "max" passed 3 arguments, but takes just 2
     max(const _Tp&, const _Tp&, _Compare);
                                         ^
/usr/include/c++/4.8.2/bits/algorithmfwd.h:371:41: error: macro "min" passed 3 arguments, but takes just 2
     min(const _Tp&, const _Tp&, _Compare);
                                         ^
/usr/include/c++/4.8.2/bits/algorithmfwd.h:394:30: error: macro "min" requires 2 arguments, but only 1 given
     min(initializer_list<_Tp>);
                              ^
/usr/include/c++/4.8.2/bits/algorithmfwd.h:402:30: error: macro "max" requires 2 arguments, but only 1 given
     max(initializer_list<_Tp>);
                              ^
In file included from /usr/include/c++/4.8.2/random:50:0,
                 from /usr/include/c++/4.8.2/bits/stl_algo.h:65,
                 from /usr/include/c++/4.8.2/algorithm:62,
                 from /opt/projects/c++/cbs/cbs/main.cpp:2:
/usr/include/c++/4.8.2/bits/random.h:173:6: error: macro "min" requires 2 arguments, but only 1 given
  min() const
      ^
/usr/include/c++/4.8.2/bits/random.h:177:6: error: macro "max" requires 2 arguments, but only 1 given
  max() const
      ^
/usr/include/c++/4.8.2/bits/random.h:311:11: error: macro "min" requires 2 arguments, but only 1 given
       min()
           ^
/usr/include/c++/4.8.2/bits/random.h:318:11: error: macro "max" requires 2 arguments, but only 1 given
       max()
           ^
/usr/include/c++/4.8.2/bits/random.h:527:11: error: macro "min" requires 2 arguments, but only 1 given
       min()
           ^
/usr/include/c++/4.8.2/bits/random.h:534:11: error: macro "max" requires 2 arguments, but only 1 given
       max()
           ^
/usr/include/c++/4.8.2/bits/random.h:736:11: error: macro "min" requires 2 arguments, but only 1 given
       min()
           ^
/usr/include/c++/4.8.2/bits/random.h:744:11: error: macro "max" requires 2 arguments, but only 1 given
       max()
           ^
/usr/include/c++/4.8.2/bits/random.h:966:11: error: macro "min" requires 2 arguments, but only 1 given
       min()
           ^
/usr/include/c++/4.8.2/bits/random.h:967:41: error: macro "min" requires 2 arguments, but only 1 given
       { return _RandomNumberEngine::min(); }
                                         ^
/usr/include/c++/4.8.2/bits/random.h:973:11: error: macro "max" requires 2 arguments, but only 1 given
       max()
           ^
/usr/include/c++/4.8.2/bits/random.h:974:41: error: macro "max" requires 2 arguments, but only 1 given
       { return _RandomNumberEngine::max(); }
                                         ^
/usr/include/c++/4.8.2/bits/random.h:1175:11: error: macro "min" requires 2 arguments, but only 1 given
       min()
           ^
/usr/include/c++/4.8.2/bits/random.h:1182:11: error: macro "max" requires 2 arguments, but only 1 given
       max()
           ^
/usr/include/c++/4.8.2/bits/random.h:1405:11: error: macro "min" requires 2 arguments, but only 1 given
       min()
           ^
/usr/include/c++/4.8.2/bits/random.h:1406:41: error: macro "min" requires 2 arguments, but only 1 given
       { return _RandomNumberEngine::min(); }
                                         ^
/usr/include/c++/4.8.2/bits/random.h:1412:11: error: macro "max" requires 2 arguments, but only 1 given
       max()
           ^
/usr/include/c++/4.8.2/bits/random.h:1413:41: error: macro "max" requires 2 arguments, but only 1 given
Process terminated with status 1 (0 minute(s), 0 second(s))
50 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 
Process terminated with status 1 (0 minute(s), 0 second(s))
50 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Code
#ifndef STAT_H_INCLUDED
#define STAT_H_INCLUDED

You can NOT reuse header defines and expect them to work!

Edit: looks like posted listed the same header twice.

Tim S.

« Last Edit: April 20, 2020, 07:21:05 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
In addition what stahta01 says:

As you can see in the log
Code
In file included from /usr/include/mysql/mysql/psi/mysql_thread.h:57:0,
                 from /usr/include/mysql/my_pthread.h:750,
                 from /usr/include/mysql/my_sys.h:34,
                 from /opt/projects/c++/cbs/cbs/product.h:5,
                 from /opt/projects/c++/cbs/cbs/product.cpp:2:
/usr/include/mysql/mysql/psi/psi.h:40:2: error: #error "You must include my_global.h in the code for the build to be correct."
 #error "You must include my_global.h in the code for the build to be correct."
The problem is that in file /mysql/psi/psi.h is a line that search  some my_global.h header check. I googled for the files (since i do not know what you are using) and found this:
Code
#ifndef MY_GLOBAL_INCLUDED
   33 /*
   34   Make sure a .c or .cc file contains an include to my_global.h first.
   35   When this include is missing, all the #ifdef HAVE_XXX have no effect,
   36   and the resulting binary won't build, or won't link,
   37   or will crash at runtime
   38   since various structures will have different binary definitions.
   39 */
   40 #error "You must include my_global.h in the code for the build to be correct."
   41 #endif
So this code looks for
Code
MY_GLOBAL_INCLUDED
  now look in your <mysql/my_global.h> if this is there If not you are using the wrong library or worng header...

Offline Rahul

  • Multiple posting newcomer
  • *
  • Posts: 25
so what should be next , How can i connect MySQL with c++