Alison
Alison

Reputation: 45

Rcpp -- could not find function "main"

I'm learning the C++ function coded in Rcpp. Below is my code

#include <iostream>
using namespace Rcpp;
using namespace std;

// [[Rcpp::export]]

int addition (int a, int b) { 
  
  int r;
  r = a + b;
  return r;
}


int main () {
  int z;
  z = addition(3, 5);
  cout << "The result is " << z;
}

/*** R
main()
*/

But when I sourceCpp, I got the error "Error in main() : could not find function "main" ".

I do not know why the compiler cannot see my defined main function.

Upvotes: 0

Views: 85

Answers (0)

Related Questions