I think you should call g95_runtime_stop() last and not before you've
made your call to get_date. I've updated my example to do more closely
what you want; I've only tested it on linux.
// C++ main
#include <iostream>
using namespace std;
extern "C" {
void g95_runtime_start(int, char**);
void g95_runtime_stop();
void now(int*, int*, int*);
}
int main(int argc, char** argv) {
g95_runtime_start(0, NULL);
cout << "Calling date_and_time ..." << endl;
int year, month, day;
now(&year, &month, &day);
cout << "anne = " << year << " ; mois = " << month << " ; jour = "
<< day << endl;
g95_runtime_stop();
}
// Fortran bit:
module datetime
contains
subroutine now(nan, nmois, njour) bind(c)
use iso_c_binding
implicit none
integer(c_int), intent(out) :: nan
integer(c_int), intent(out) :: nmois
integer(c_int), intent(out) :: njour
character(len=8) :: today
integer :: vals(8)
call date_and_time(date=today,values=vals)
write(*,'(a)') 'Today is '//today(7:8)//'/'//today(5:6)//'/'//today
(1:4)
nan = vals(1)
nmois = vals(2)
njour = vals(3)
end subroutine now
end module datetime