🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.comp.lang.learn.c-c++
2 messages
2 total messages Started by Rubber Ducky Sun, 27 May 2001 17:47
Error MYSQL.H LineNo Too many types in declaration
#674
Author: Rubber Ducky
Date: Sun, 27 May 2001 17:47
99 lines
4722 bytes
Welcome and thanks for the time in reading this.  I have a simple proggie
below.  When I try and compile it I get the error above (subject) the error
points to this part of mysql.h - the part specifically is highlighted in
red.

I am compiling it on Win2K SP2 with Borland C++ v4.52
I can't see any reason why this wouldn't work. Can you??


I also get 5 warnings:
WARNING MYSQL.CPP LineNo: Temporary used for parameter 1 in call  to
'istream::operator >> (int &)' in function main()
-  Well seeing as I have a problem anyway it seems silly not to mention it!

<extract from mysql.h>
#if defined(NO_CLIENT_LONG_LONG)
typedef unsigned long my_ulonglong;
#elif defined (__WIN__)
typedef unsigned __int64 my_ulonglong;
#else
typedef unsigned long long my_ulonglong;
#endif
<end of extract>


<CODE>

////////////////////////////////////////////////////////////////////////////
////
// Program: Client proggie to connect to mysql server.  Server options are
// specified by the user
// Aim: To retrieve data from table specified by user in Microsoft access
format
// and insert the table into a Microsoft access database of the users choice
//
//  Command line version of the program currently being investigated
//  I.e. c:\this_proggie -h host -u user -p pass -po port
//
// Start of development: 24th May 2001
// Date modified: 27th May 2001
// Author: David Ayliffe
// Version: 0.1
////////////////////////////////////////////////////////////////////////////
////

#include <stdio.h>
#include <iostream.h> // libraries included in the linked (object) file
#include <conio.h>
#include "mysql.h"      // include the mysql libraries copied from the win
        // source download

#define def_host_name NULL /*host to connecto to (default localhost) */
#define def_user_name NULL /*user name for the database (default login name)
*/
#define def_password  NULL /*password for the database (default is null) */
#define def_db_name   NULL /*default database (default database default
none) */
#define def_svr_port  NULL /*port to connect to (default 3306) */

MYSQL  *conn;              /*pointer to the connection handle */

int main ()
{
 clrscr();
 cout << "Enter the host name (default localhost): ";
 cin >> def_host_name;
 cout << "Enter the user name (default root): ";
 cin >> def_user_name;
 cout << "Enter the password (default blank): ";
 cin >> def_password;
 cout << "Enter the database name (default none): ";
 cin >> def_db_name;
 cout << "Enter the port (default 3306): ";
 cin >> def_db_name;

 // the real work starts here

 conn = mysql_init (NULL);
 mysql_real_connect (
      conn,                  // pointer to connection handle
      def_host_name,         // host to connect to
      def_user_name,         // user name to connect as
      def_password,          // password to use
      def_db_name,           // database to use
      def_svr_port,          // port to connect through
      NULL,                  // socket
      0);                    // flags

 mysql_close (conn);
 return 0;
}

<\CODE>
--
Thanks
Rubber Ducky

Please reply to group or to email
To reply to email remove NOSPAM
Re: Error MYSQL.H LineNo Too many types in declaration
#675
Author: Phlip
Date: Sun, 27 May 2001 18:07
19 lines
1920 bytes
Proclaimed Rubber Ducky from the mountaintops:

> #define def_host_name NULL /*host to connecto to (default localhost) */

>  cin >> def_host_name;

Please learn some C++ before diving into a custom library like MySQL.lib.

In this case, you used #define to tell the compiler to replace every 
"def_host_name" it sees with "NULL". NULL is typically 0.

Then you say 'cin >> 0', and the compiler goes "wha??".

Read /Accelerate C++/, and then use the 'std::string' object.

-- 
  Phlip                          phlip_cpp@my-deja.com
============== http://phlip.webjump.com ==============
  --  Sampling is the sincerest form of flattery  --
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads