- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Intel Community,
Hope the message finds you well. May I ask a question related Intel SGX. Recently I need use C++'s template class in Intel SGX, and referred from SGX developer guide, the C++ template class should has been enabled in the latest versions. But when I try to use the template class in Intel SGX, it always exits and reports error: Invalid token: <
The function at Enclave.edl is:
template<typename T>
public void template_test_sgx(int a);
And the function at Enclave.cpp is:
template<typename T>
void template_test_sgx(int a){
printf("Here is template usage in SGX\n");
}
Thank you for your help! Have a nice day!
Best Regards,
Jin Xin
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A general valid cpp syntax doesn't have "<>" symbol in the declaration of variables. That is why you were getting "Invalid token: <" error.
From the documentation that you share, the template is an illustration of how you can use a cpp function in Intel SGX.
template< class T, std::size_t A, std::size_t... OLs> is equivalent to creating a function like this in cpp (The class template can’t be used in pure cpp code):
Typedef struct {
size_t offset; size_t len;
} align_req_t;
void *sgx_get_aligned_ptr(void *raw, size_t raw_size, size_t allocate_size, size_t alignment, align_req_t *data, size_t count);
You may refer to this;
Cordially,
Iffa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear lffa,
Thank you for your nice reply! I'm not sure if your misunderstand the usage of C++'s "<template>", it is a kind of Generic programming method instead of how to use cpp in SGX. If there are any misunderstanding from my side, feel free to indicate
Best Regards,
Jin Xin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
as mentioned before (mentioned in the official SGX documentation shared by you), the class template can’t be used in pure cpp code, hence, the function below is used:
Typedef struct {
size_t offset; size_t len;
} align_req_t;
void *sgx_get_aligned_ptr(void *raw, size_t raw_size, size_t allocate_size, size_t alignment, align_req_t *data, size_t count);
We highly recommend that you refer to these Official Intel SGX sample codes that are officially validated.
Cordially,
Iffa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Intel will no longer monitor this thread since we have provided a solution. If you need any additional information from Intel, please submit a new question.
Cordially,
Iffa
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page