Hello Jifi, all

Those conditional macros should not be required.

Is your GLPK code is a 'main' function?  Maybe the
global declarations work until the GLPK function call
that chokes?

See here for a simple example:

  
http://en.wikibooks.org/wiki/GLPK/Using_the_GLPK_callable_library#Short_example

In addition, this is not good style:

  using namespace std;

See:

  
http://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice

Instead use:

  std::cout << "Message" << std::endl;

Finally constants can help avoid bugs:

  const int C = 6;

HTH, Robbie

------------------------------------------------------------
To:           Help Glpk <help-glpk@gnu.org>
Subject:      Re: [Help-glpk] glpk Limitation? Or what is the problem
Message-ID:  <51c1c890.9050...@bluetone.cz>
From:         Ji?? Spitz <jiri.sp...@bluetone.cz>
Date:         Wed, 19 Jun 2013 17:04:48 +0200
------------------------------------------------------------

> Hi!
>
> You are calling C functions from C++. All C code
> should be embeddes in something like:
>
> #ifdef __cplusplus
> extern "C" {
> #endif
>
>     int C = 30;
>     int H = 30;
>     int R = 6;
>
>     glp_prob *lp;
>
>     int ia[1 + C*H*R + C*R], ja[1 + C*H*R + C*R];
>
>     double ar[1 + C*H*R + C*R], z;
>
> #ifdef __cplusplus
>    }
> #endif
>
>     cout<<"Basic matrices of LP problem are defined"<<"\n";
>
> #ifdef __cplusplus
> extern "C" {
> #endif
>
>     lp = glp_create_prob();
>
> #ifdef __cplusplus
>    }
> #endif
>
> Alternatively you can define C++ wrapper functions and call them
> directly from C++.
>
> Jiri
>
>>
>>   int C = 30;
>>   int H = 30;
>>   int R = 6;
>>
>>   glp_prob *lp;
>>
>>   int ia[1 + C*H*R + C*R], ja[1 + C*H*R + C*R];
>>
>>   double ar[1 + C*H*R + C*R], z;
>>
>>   cout<<"Basic matrices of LP problem are defined"<<"\n";
>>
>>   lp = glp_create_prob();

---
Robbie Morrison
PhD student -- policy-oriented energy system simulation
Technical University of Berlin (TU-Berlin), Germany
University email (redirected) : morri...@iet.tu-berlin.de
Webmail (preferred)           : rob...@actrix.co.nz
[from Webmail client]



_______________________________________________
Help-glpk mailing list
Help-glpk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-glpk

Reply via email to