0

I'm using a goto statement to skip a piece of code (as per documentation), just for testing purposes while I debug a block of code. I'm getting an error 1526, "goto into protected scope". This is totally trivial I know, but I want to know what is wrong with how I'm using the goto code:

#if defined(_PLAT_ANDROID)
_di_JIntent MyIntent;
 MyIntent = TJIntent::JavaClass->init(TJIntent::JavaClass->ACTION_VIEW,
 TJnet_Uri::JavaClass->parse(StringToJString("http://relayman.org/papers/2009_FDA_paper.pdf")));
 TAndroidHelper::Activity->startActivity(MyIntent);


goto Skipit;
 Androidapi::Jni::Graphicscontentviewtext::_di_JIntent intent = TJIntent::Create();
 intent->setDataAndType(StringToJString("file://" + System::Ioutils::TPath::Combine(System::Ioutils::TPath::GetSharedDownloadsPath(), "sample.pdf")), StringToJString(L"application/pdf"));
 intent->setAction(TJIntent::JavaClass->ACTION_VIEW);
 intent->setFlags(TJIntent::JavaClass->FLAG_GRANT_READ_URI_PERMISSION);
 if (SharedActivity()->getPackageManager()->queryIntentActivities(intent, TJPackageManager::JavaClass->MATCH_DEFAULT_ONLY)->size() > 0) {
    SharedActivity()->startActivity(intent);
 } else {
    ShowMessage("PDF viewer not found");
 }
Skipit:
#endif

I'm working in 10.3.2 and building toward Android target.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
relayman357
  • 793
  • 1
  • 6
  • 30
  • 1
    I was told goto makes babies cry :-/ I don't use it any more after that – bbozo Nov 19 '19 at 19:00
  • 2
    In this situation, I would use `#if 0 ... #endif` or `/* ... */` instead of `goto`. As for the error, it has to do with ARC handling. `goto` can't jump into a scope that initializes ARC-managed resources. If you introduce a new scope after the `goto` around the offending code, it should work. See [ARC + goto into protected scope error](http://clang-developers.42468.n3.nabble.com/ARC-goto-into-protected-scope-error-td4026204.html). – Remy Lebeau Nov 23 '19 at 02:51

0 Answers0